38 require
'../main.inc.php';
39 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
40 require_once DOL_DOCUMENT_ROOT.
'/user/class/usergroup.class.php';
41 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
42 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
43 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
44 require_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
45 require_once DOL_DOCUMENT_ROOT.
'/core/lib/usergroups.lib.php';
46 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
47 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
48 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
49 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
50 require_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
51 if (!empty($conf->ldap->enabled)) {
52 require_once DOL_DOCUMENT_ROOT.
'/core/class/ldap.class.php';
54 if (!empty($conf->adherent->enabled)) {
55 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
57 if (!empty($conf->categorie->enabled)) {
58 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
60 if (!empty($conf->stock->enabled)) {
61 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
65 $action =
GETPOST(
'action',
'aZ09');
66 $mode =
GETPOST(
'mode',
'alpha');
67 $confirm =
GETPOST(
'confirm',
'alpha');
68 $group =
GETPOST(
"group",
"int", 3);
69 $cancel =
GETPOST(
'cancel',
'alpha');
70 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'useracard';
72 $dateemployment =
dol_mktime(0, 0, 0,
GETPOST(
'dateemploymentmonth',
'int'),
GETPOST(
'dateemploymentday',
'int'),
GETPOST(
'dateemploymentyear',
'int'));
73 $dateemploymentend =
dol_mktime(0, 0, 0,
GETPOST(
'dateemploymentendmonth',
'int'),
GETPOST(
'dateemploymentendday',
'int'),
GETPOST(
'dateemploymentendyear',
'int'));
74 $datestartvalidity =
dol_mktime(0, 0, 0,
GETPOST(
'datestartvaliditymonth',
'int'),
GETPOST(
'datestartvalidityday',
'int'),
GETPOST(
'datestartvalidityyear',
'int'));
75 $dateendvalidity =
dol_mktime(0, 0, 0,
GETPOST(
'dateendvaliditymonth',
'int'),
GETPOST(
'dateendvalidityday',
'int'),
GETPOST(
'dateendvalidityyear',
'int'));
79 $canadduser = (!empty($user->admin) || $user->rights->user->user->creer);
80 $canreaduser = (!empty($user->admin) || $user->rights->user->user->lire);
81 $canedituser = (!empty($user->admin) || $user->rights->user->user->creer);
82 $candisableuser = (!empty($user->admin) || $user->rights->user->user->supprimer);
83 $canreadgroup = $canreaduser;
84 $caneditgroup = $canedituser;
85 if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
86 $canreadgroup = (!empty($user->admin) || $user->rights->user->group_advance->read);
87 $caneditgroup = (!empty($user->admin) || $user->rights->user->group_advance->write);
90 $childids = $user->getAllChildIds(1);
95 $caneditfield = ((($user->id == $id) && $user->rights->user->self->creer) || (($user->id != $id) && $user->rights->user->user->creer));
96 $caneditpassword = ((($user->id == $id) && $user->rights->user->self->password) || (($user->id != $id) && $user->rights->user->user->password));
101 if ($user->socid > 0) {
102 $socid = $user->socid;
107 if ($user->id != $id && !$canreaduser) {
112 $langs->loadLangs(array(
'users',
'companies',
'ldap',
'admin',
'hrm',
'stocks',
'other'));
114 $object =
new User($db);
118 $extrafields->fetch_name_optionals_label($object->table_element);
123 $hookmanager->initHooks(array(
'usercard',
'globalcard'));
132 $parameters = array(
'id' => $id,
'socid' => $socid,
'group' => $group,
'caneditgroup' => $caneditgroup);
133 $reshook = $hookmanager->executeHooks(
'doActions',
$parameters, $object, $action);
138 if (empty($reshook)) {
139 $backurlforlist = DOL_URL_ROOT.
'/user/list.php';
141 if (empty($backtopage) || ($cancel && empty($id))) {
142 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
143 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
144 $backtopage = $backurlforlist;
146 $backtopage = DOL_URL_ROOT.
'/user/card.php?id='.((!empty($id) && $id > 0) ? $id :
'__ID__');
152 if (!empty($backtopageforcancel)) {
153 header(
"Location: ".$backtopageforcancel);
155 } elseif (!empty($backtopage)) {
156 header(
"Location: ".$backtopage);
162 if ($action ==
'confirm_disable' && $confirm ==
"yes" && $candisableuser) {
163 if ($id != $user->id) {
165 if ($object->admin && empty($user->admin)) {
168 setEventMessages($langs->trans(
"OnlyAdminUsersCanDisableAdminUsers"),
null,
'errors');
170 $object->setstatus(0);
171 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$id);
177 if ($action ==
'confirm_enable' && $confirm ==
"yes" && $candisableuser) {
180 if ($id != $user->id) {
183 if (!empty($conf->file->main_limit_users)) {
184 $nb = $object->getNbOfUsers(
"active");
185 if ($nb >= $conf->file->main_limit_users) {
187 setEventMessages($langs->trans(
"YourQuotaOfUsersIsReached"),
null,
'errors');
192 $object->setstatus(1);
193 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$id);
199 if ($action ==
'confirm_delete' && $confirm ==
"yes" && $candisableuser) {
200 if ($id != $user->id) {
202 print
'Error, token required for this critical operation';
206 $object =
new User($db);
208 $object->oldcopy = clone $object;
210 $result = $object->delete($user);
212 $langs->load(
"errors");
216 header(
"Location: ".DOL_URL_ROOT.
"/user/list.php?restore_lastsearch_values=1");
223 if ($action ==
'add' && $canadduser) {
237 if (!empty($conf->file->main_limit_users)) {
238 $nb = $object->getNbOfUsers(
"active");
239 if ($nb >= $conf->file->main_limit_users) {
241 setEventMessages($langs->trans(
"YourQuotaOfUsersIsReached"),
null,
'errors');
247 $object->civility_code =
GETPOST(
"civility_code",
'aZ09');
248 $object->lastname =
GETPOST(
"lastname",
'alphanohtml');
249 $object->firstname =
GETPOST(
"firstname",
'alphanohtml');
250 $object->ref_employee =
GETPOST(
"ref_employee",
'alphanohtml');
251 $object->national_registration_number =
GETPOST(
"national_registration_number",
'alphanohtml');
252 $object->login =
GETPOST(
"login",
'alphanohtml');
253 $object->api_key =
GETPOST(
"api_key",
'alphanohtml');
254 $object->gender =
GETPOST(
"gender",
'aZ09');
255 $object->admin =
GETPOST(
"admin",
'int');
256 $object->address =
GETPOST(
'address',
'alphanohtml');
257 $object->zip =
GETPOST(
'zipcode',
'alphanohtml');
258 $object->town =
GETPOST(
'town',
'alphanohtml');
259 $object->country_id =
GETPOST(
'country_id',
'int');
260 $object->state_id =
GETPOST(
'state_id',
'int');
261 $object->office_phone =
GETPOST(
"office_phone",
'alphanohtml');
262 $object->office_fax =
GETPOST(
"office_fax",
'alphanohtml');
263 $object->user_mobile =
GETPOST(
"user_mobile",
'alphanohtml');
265 if (!empty($conf->socialnetworks->enabled)) {
266 $object->socialnetworks = array();
267 foreach ($socialnetworks as $key => $value) {
268 if (
GETPOST($key,
'alphanohtml')) {
269 $object->socialnetworks[$key] =
GETPOST($key,
'alphanohtml');
274 $object->email = preg_replace(
'/\s+/',
'',
GETPOST(
"email",
'alphanohtml'));
275 $object->job =
GETPOST(
"job",
'alphanohtml');
276 $object->signature =
GETPOST(
"signature",
'restricthtml');
277 $object->accountancy_code =
GETPOST(
"accountancy_code",
'alphanohtml');
278 $object->note =
GETPOST(
"note",
'restricthtml');
279 $object->note_private =
GETPOST(
"note",
'restricthtml');
280 $object->ldap_sid =
GETPOST(
"ldap_sid",
'alphanohtml');
281 $object->fk_user =
GETPOST(
"fk_user",
'int') > 0 ?
GETPOST(
"fk_user",
'int') : 0;
282 $object->fk_user_expense_validator =
GETPOST(
"fk_user_expense_validator",
'int') > 0 ?
GETPOST(
"fk_user_expense_validator",
'int') : 0;
283 $object->fk_user_holiday_validator =
GETPOST(
"fk_user_holiday_validator",
'int') > 0 ?
GETPOST(
"fk_user_holiday_validator",
'int') : 0;
284 $object->employee =
GETPOST(
'employee',
'alphanohtml');
286 $object->thm =
GETPOST(
"thm",
'alphanohtml') !=
'' ?
GETPOST(
"thm",
'alphanohtml') :
'';
288 $object->tjm =
GETPOST(
"tjm",
'alphanohtml') !=
'' ?
GETPOST(
"tjm",
'alphanohtml') :
'';
290 $object->salary =
GETPOST(
"salary",
'alphanohtml') !=
'' ?
GETPOST(
"salary",
'alphanohtml') :
'';
291 $object->salary =
price2num($object->salary);
292 $object->salaryextra =
GETPOST(
"salaryextra",
'alphanohtml') !=
'' ?
GETPOST(
"salaryextra",
'alphanohtml') :
'';
293 $object->weeklyhours =
GETPOST(
"weeklyhours",
'alphanohtml') !=
'' ?
GETPOST(
"weeklyhours",
'alphanohtml') :
'';
295 $object->color =
GETPOST(
"color",
'alphanohtml') !=
'' ?
GETPOST(
"color",
'alphanohtml') :
'';
297 $object->dateemployment = $dateemployment;
298 $object->dateemploymentend = $dateemploymentend;
299 $object->datestartvalidity = $datestartvalidity;
300 $object->dateendvalidity = $dateendvalidity;
301 $object->birth = $dateofbirth;
303 $object->fk_warehouse =
GETPOST(
'fk_warehouse',
'int');
305 $object->lang =
GETPOST(
'default_lang',
'aZ09');
308 $ret = $extrafields->setOptionalsFromPost(
null, $object);
314 $entity =
GETPOST(
'entity',
'int');
315 if (!empty($conf->multicompany->enabled)) {
316 if (
GETPOST(
'superadmin',
'int')) {
319 if (!empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
322 $object->entity = ($entity ==
'' ? 1 : $entity);
326 $object->entity = ($entity ==
'' ? 1 : $entity);
334 $id = $object->create($user);
337 if (
GETPOST(
'password',
'none')) {
338 $resPass = $object->setPassword($user,
GETPOST(
'password',
'none'));
341 $langs->load(
"errors");
346 if (! empty($conf->categorie->enabled)) {
348 $usercats =
GETPOST(
'usercats',
'array');
349 $object->setCategories($usercats);
353 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$id);
357 $langs->load(
"errors");
366 if (($action ==
'addgroup' || $action ==
'removegroup') && $caneditgroup) {
369 $editgroup->fetch($group);
370 $editgroup->oldcopy = clone $editgroup;
373 if ($action ==
'addgroup') {
374 $result = $object->SetInGroup($group, $editgroup->entity);
376 if ($action ==
'removegroup') {
377 $result = $object->RemoveFromGroup($group, $editgroup->entity);
388 if ($action ==
'update' && !$cancel) {
389 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
394 if (!
GETPOST(
"lastname",
'alpha')) {
399 if (!
GETPOST(
"login",
'alpha')) {
408 $object->oldcopy = clone $object;
412 $object->civility_code =
GETPOST(
"civility_code",
'aZ09');
413 $object->lastname =
GETPOST(
"lastname",
'alphanohtml');
414 $object->firstname =
GETPOST(
"firstname",
'alphanohtml');
415 $object->ref_employee =
GETPOST(
"ref_employee",
'alphanohtml');
416 $object->national_registration_number =
GETPOST(
"national_registration_number",
'alphanohtml');
417 $object->gender =
GETPOST(
"gender",
'aZ09');
418 $object->pass =
GETPOST(
"password",
'none');
419 $object->api_key = (
GETPOST(
"api_key",
'alphanohtml')) ?
GETPOST(
"api_key",
'alphanohtml') : $object->api_key;
420 if (!empty($user->admin)) {
421 $object->admin =
GETPOST(
"admin",
"int");
423 if ($user->admin && !$object->ldap_sid) {
424 $object->login =
GETPOST(
"login",
'alphanohtml');
426 $object->address =
GETPOST(
'address',
'alphanohtml');
427 $object->zip =
GETPOST(
'zipcode',
'alphanohtml');
428 $object->town =
GETPOST(
'town',
'alphanohtml');
429 $object->country_id =
GETPOST(
'country_id',
'int');
430 $object->state_id =
GETPOST(
'state_id',
'int');
431 $object->office_phone =
GETPOST(
"office_phone",
'alphanohtml');
432 $object->office_fax =
GETPOST(
"office_fax",
'alphanohtml');
433 $object->user_mobile =
GETPOST(
"user_mobile",
'alphanohtml');
435 if (!empty($conf->socialnetworks->enabled)) {
436 $object->socialnetworks = array();
437 foreach ($socialnetworks as $key => $value) {
438 if (
GETPOST($key,
'alphanohtml')) {
439 $object->socialnetworks[$key] =
GETPOST($key,
'alphanohtml');
444 $object->email = preg_replace(
'/\s+/',
'',
GETPOST(
"email",
'alphanohtml'));
445 $object->job =
GETPOST(
"job",
'alphanohtml');
446 $object->signature =
GETPOST(
"signature",
'restricthtml');
447 $object->accountancy_code =
GETPOST(
"accountancy_code",
'alphanohtml');
448 $object->openid =
GETPOST(
"openid",
'alphanohtml');
449 $object->fk_user =
GETPOST(
"fk_user",
'int') > 0 ?
GETPOST(
"fk_user",
'int') : 0;
450 $object->fk_user_expense_validator =
GETPOST(
"fk_user_expense_validator",
'int') > 0 ?
GETPOST(
"fk_user_expense_validator",
'int') : 0;
451 $object->fk_user_holiday_validator =
GETPOST(
"fk_user_holiday_validator",
'int') > 0 ?
GETPOST(
"fk_user_holiday_validator",
'int') : 0;
452 $object->employee =
GETPOST(
'employee',
'int');
454 $object->thm =
GETPOST(
"thm",
'alphanohtml') !=
'' ?
GETPOST(
"thm",
'alphanohtml') :
'';
456 $object->tjm =
GETPOST(
"tjm",
'alphanohtml') !=
'' ?
GETPOST(
"tjm",
'alphanohtml') :
'';
458 $object->salary =
GETPOST(
"salary",
'alphanohtml') !=
'' ?
GETPOST(
"salary",
'alphanohtml') :
'';
459 $object->salary =
price2num($object->salary);
460 $object->salaryextra =
GETPOST(
"salaryextra",
'alphanohtml') !=
'' ?
GETPOST(
"salaryextra",
'alphanohtml') :
'';
461 $object->salaryextra =
price2num($object->salaryextra);
462 $object->weeklyhours =
GETPOST(
"weeklyhours",
'alphanohtml') !=
'' ?
GETPOST(
"weeklyhours",
'alphanohtml') :
'';
463 $object->weeklyhours =
price2num($object->weeklyhours);
465 $object->color =
GETPOST(
"color",
'alphanohtml') !=
'' ?
GETPOST(
"color",
'alphanohtml') :
'';
466 $object->dateemployment = $dateemployment;
467 $object->dateemploymentend = $dateemploymentend;
468 $object->datestartvalidity = $datestartvalidity;
469 $object->dateendvalidity = $dateendvalidity;
470 $object->birth = $dateofbirth;
472 if (!empty($conf->stock->enabled)) {
473 $object->fk_warehouse =
GETPOST(
'fk_warehouse',
'int');
476 $object->lang =
GETPOST(
'default_lang',
'aZ09');
479 if (!empty($conf->multicompany->enabled) && empty($user->entity) && !empty($user->admin)) {
480 if (
GETPOST(
'superadmin',
'int')) {
483 if (!empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
493 $ret = $extrafields->setOptionalsFromPost(
null, $object,
'@GETPOSTISSET');
501 if (!empty($_FILES[
'photo'][
'name'])) {
507 $langs->load(
"errors");
509 dol_syslog($langs->transnoentities(
"ErrorBadImageFormat"), LOG_INFO);
514 $ret = $object->update($user);
517 if ($db->errno() ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
518 $langs->load(
"errors");
519 setEventMessages($langs->trans(
"ErrorLoginAlreadyExists", $object->login),
null,
'errors');
528 $contactid =
GETPOST(
'contactid',
'int');
529 $socid =
GETPOST(
'socid',
'int');
531 if ($contactid > 0) {
533 $contact->fetch($contactid);
535 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user";
536 $sql .=
" SET fk_socpeople=".((int) $contactid);
537 if (!empty($contact->socid)) {
538 $sql .=
", fk_soc=".((int) $contact->socid);
540 $sql .=
" WHERE rowid = ".((int) $object->id);
541 } elseif ($socid > 0) {
542 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user";
543 $sql .=
" SET fk_socpeople=NULL, fk_soc=".((int) $socid);
544 $sql .=
" WHERE rowid = ".((int) $object->id);
546 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user";
547 $sql .=
" SET fk_socpeople=NULL, fk_soc=NULL";
548 $sql .=
" WHERE rowid = ".((int) $object->id);
551 $resql = $db->query($sql);
558 if (!$error && !count($object->errors)) {
559 if (
GETPOST(
'deletephoto') && $object->oldcopy->photo) {
560 $fileimg = $conf->user->dir_output.
'/'.
get_exdir(0, 0, 0, 0, $object,
'user').
'photos/'.$object->oldcopy->photo;
561 $dirthumbs = $conf->user->dir_output.
'/'.
get_exdir(0, 0, 0, 0, $object,
'user').
'photos/thumbs';
566 if (isset($_FILES[
'photo'][
'tmp_name']) && trim($_FILES[
'photo'][
'tmp_name'])) {
567 $dir = $conf->user->dir_output.
'/'.
get_exdir(0, 0, 0, 1, $object,
'user').
'/photos';
573 $result =
dol_move_uploaded_file($_FILES[
'photo'][
'tmp_name'], $newfile, 1, 0, $_FILES[
'photo'][
'error']);
575 if (!($result > 0)) {
579 $object->addThumbs($newfile);
583 $langs->load(
"errors");
584 setEventMessages($langs->trans(
"ErrorFailedToCreateDir", $dir), $mesgs,
'errors');
589 if (!$error && !count($object->errors)) {
591 $categories =
GETPOST(
'usercats',
'array');
592 $object->setCategories($categories);
595 if (!$error && !count($object->errors)) {
599 $login = $_SESSION[
"dol_login"];
600 if ($login && $login == $object->oldcopy->login && $object->oldcopy->login != $object->login) {
602 $langs->load(
"errors");
603 setEventMessages($langs->transnoentitiesnoconv(
"WarningYourLoginWasModifiedPleaseLogin"),
null,
'warnings');
610 if ($caneditpassword) {
611 dol_syslog(
"Not allowed to change fields, only password");
615 if (
GETPOST(
"password",
"none")) {
616 $object->oldcopy = clone $object;
618 $ret = $object->setPassword($user,
GETPOST(
"password",
"none"));
628 if ((($action ==
'confirm_password' && $confirm ==
'yes')
629 || ($action ==
'confirm_passwordsend' && $confirm ==
'yes')) && $caneditpassword
633 $newpassword = $object->setPassword($user,
'');
634 if ($newpassword < 0) {
636 setEventMessages($langs->trans(
"ErrorFailedToSetNewPassword"),
null,
'errors');
639 if ($action ==
'confirm_passwordsend' && $confirm ==
'yes') {
640 if ($object->send_password($user, $newpassword) > 0) {
641 setEventMessages($langs->trans(
"PasswordChangedAndSentTo", $object->email),
null,
'mesgs');
646 setEventMessages($langs->trans(
"PasswordChangedTo", $newpassword),
null,
'warnings');
652 if ($action ==
'adduserldap' && $canadduser) {
653 $selecteduser =
GETPOST(
'users');
655 $required_fields = array(
656 $conf->global->LDAP_KEY_USERS,
657 $conf->global->LDAP_FIELD_NAME,
658 $conf->global->LDAP_FIELD_FIRSTNAME,
659 $conf->global->LDAP_FIELD_LOGIN,
660 $conf->global->LDAP_FIELD_LOGIN_SAMBA,
661 $conf->global->LDAP_FIELD_PASSWORD,
662 $conf->global->LDAP_FIELD_PASSWORD_CRYPTED,
663 $conf->global->LDAP_FIELD_PHONE,
664 $conf->global->LDAP_FIELD_FAX,
665 $conf->global->LDAP_FIELD_MOBILE,
666 $conf->global->LDAP_FIELD_SKYPE,
667 $conf->global->LDAP_FIELD_MAIL,
668 $conf->global->LDAP_FIELD_TITLE,
669 $conf->global->LDAP_FIELD_DESCRIPTION,
670 $conf->global->LDAP_FIELD_SID
674 $result = $ldap->connect_bind();
677 $required_fields = array_unique(array_values(array_filter($required_fields,
"dol_validElement")));
679 $ldapusers = $ldap->getRecords($selecteduser, $conf->global->LDAP_USER_DN, $conf->global->LDAP_KEY_USERS, $required_fields);
682 if (is_array($ldapusers)) {
683 foreach ($ldapusers as $key => $attribute) {
684 $ldap_lastname = $attribute[$conf->global->LDAP_FIELD_NAME];
685 $ldap_firstname = $attribute[$conf->global->LDAP_FIELD_FIRSTNAME];
686 $ldap_login = $attribute[$conf->global->LDAP_FIELD_LOGIN];
687 $ldap_loginsmb = $attribute[$conf->global->LDAP_FIELD_LOGIN_SAMBA];
688 $ldap_pass = $attribute[$conf->global->LDAP_FIELD_PASSWORD];
689 $ldap_pass_crypted = $attribute[$conf->global->LDAP_FIELD_PASSWORD_CRYPTED];
690 $ldap_phone = $attribute[$conf->global->LDAP_FIELD_PHONE];
691 $ldap_fax = $attribute[$conf->global->LDAP_FIELD_FAX];
692 $ldap_mobile = $attribute[$conf->global->LDAP_FIELD_MOBILE];
693 $ldap_social[
'skype'] = $attribute[$conf->global->LDAP_FIELD_SKYPE];
694 $ldap_social[
'twitter'] = $attribute[$conf->global->LDAP_FIELD_TWITTER];
695 $ldap_social[
'facebook'] = $attribute[$conf->global->LDAP_FIELD_FACEBOOK];
696 $ldap_social[
'linkedin'] = $attribute[$conf->global->LDAP_FIELD_LINKEDIN];
697 $ldap_mail = $attribute[$conf->global->LDAP_FIELD_MAIL];
698 $ldap_sid = $attribute[$conf->global->LDAP_FIELD_SID];
707 $triggersendname =
'USER_SENTBYMAIL';
709 $mode =
'emailfromuser';
710 $trackid =
'use'.$id;
711 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
714 $upload_dir = $conf->user->dir_output;
715 $permissiontoadd = $user->rights->user->user->creer;
716 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
729 if (!empty($conf->stock->enabled)) {
733 llxHeader(
'', $langs->trans(
"UserCard"));
735 if ($action ==
'create' || $action ==
'adduserldap') {
738 print
'<span class="opacitymedium">'.$langs->trans(
"CreateInternalUserDesc").
"</span><br>\n";
745 $result = $ldap->connect_bind();
747 $required_fields = array(
748 $conf->global->LDAP_KEY_USERS,
749 $conf->global->LDAP_FIELD_FULLNAME,
750 $conf->global->LDAP_FIELD_NAME,
751 $conf->global->LDAP_FIELD_FIRSTNAME,
752 $conf->global->LDAP_FIELD_LOGIN,
753 $conf->global->LDAP_FIELD_LOGIN_SAMBA,
754 $conf->global->LDAP_FIELD_PASSWORD,
755 $conf->global->LDAP_FIELD_PASSWORD_CRYPTED,
756 $conf->global->LDAP_FIELD_PHONE,
757 $conf->global->LDAP_FIELD_FAX,
758 $conf->global->LDAP_FIELD_MOBILE,
759 $conf->global->LDAP_FIELD_SKYPE,
760 $conf->global->LDAP_FIELD_MAIL,
761 $conf->global->LDAP_FIELD_TITLE,
762 $conf->global->LDAP_FIELD_DESCRIPTION,
763 $conf->global->LDAP_FIELD_SID
767 $required_fields = array_unique(array_values(array_filter($required_fields,
"dol_validElement")));
770 $ldapusers = $ldap->getRecords(
'*', $conf->global->LDAP_USER_DN, $conf->global->LDAP_KEY_USERS, $required_fields, 1);
772 if (is_array($ldapusers)) {
774 foreach ($ldapusers as $key => $ldapuser) {
777 foreach ($required_fields as $value) {
778 if ($value === $conf->global->LDAP_FIELD_PASSWORD || $value === $conf->global->LDAP_FIELD_PASSWORD_CRYPTED) {
779 $label .= $value.
"=******* ";
781 $label .= $value.
"=".$ldapuser[$value].
" ";
784 $liste[$key] = $label;
794 print
"\n\n<!-- Form liste LDAP debut -->\n";
796 print
'<form name="add_user_ldap" action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
797 print
'<input type="hidden" name="token" value="'.newToken().
'">';
798 print
'<table class="border centpercent"><tr>';
799 print
'<td width="160">';
800 print $langs->trans(
"LDAPUsers");
803 print
'<input type="hidden" name="action" value="adduserldap">';
804 if (is_array($liste) && count($liste)) {
805 print
$form->selectarray(
'users', $liste,
'', 1, 0, 0,
'', 0, 0, 0,
'',
'maxwidth500');
808 print
'</td><td class="center">';
809 print
'<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans(
'Get')).
'"'.(count($liste) ?
'' :
' disabled').
'>';
810 print
'</td></tr></table>';
813 print
"\n<!-- Form liste LDAP fin -->\n\n";
818 print
'<form action="'.$_SERVER[
'PHP_SELF'].
'" method="POST" name="createuser">';
819 print
'<input type="hidden" name="token" value="'.newToken().
'">';
820 print
'<input type="hidden" name="action" value="add">';
821 if (!empty($ldap_sid)) {
822 print
'<input type="hidden" name="ldap_sid" value="'.dol_escape_htmltag($ldap_sid).
'">';
824 print
'<input type="hidden" name="entity" value="'.$conf->entity.
'">';
830 print
'<table class="border centpercent">';
833 print
'<tr><td><label for="civility_code">'.$langs->trans(
"UserTitle").
'</label></td><td colspan="3">';
834 print $formcompany->select_civility(
GETPOSTISSET(
"civility_code") ?
GETPOST(
"civility_code",
'aZ09') : $object->civility_code,
'civility_code');
839 print
'<td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans(
"Lastname").
'</span></td>';
841 if (!empty($ldap_lastname)) {
842 print
'<input type="hidden" id="lastname" name="lastname" value="'.dol_escape_htmltag($ldap_lastname).
'">';
843 print $ldap_lastname;
845 print
'<input class="minwidth100 maxwidth150onsmartphone" type="text" id="lastname" name="lastname" value="'.dol_escape_htmltag(
GETPOST(
'lastname',
'alphanohtml')).
'">';
850 print
'<tr><td>'.$langs->trans(
"Firstname").
'</td>';
852 if (!empty($ldap_firstname)) {
853 print
'<input type="hidden" name="firstname" value="'.dol_escape_htmltag($ldap_firstname).
'">';
854 print $ldap_firstname;
856 print
'<input class="minwidth100 maxwidth150onsmartphone" type="text" name="firstname" value="'.dol_escape_htmltag(
GETPOST(
'firstname',
'alphanohtml')).
'">';
861 print
'<tr><td><span class="fieldrequired">'.$langs->trans(
"Login").
'</span></td>';
863 if (!empty($ldap_login)) {
864 print
'<input type="hidden" name="login" value="'.dol_escape_htmltag($ldap_login).
'">';
866 } elseif (!empty($ldap_loginsmb)) {
867 print
'<input type="hidden" name="login" value="'.dol_escape_htmltag($ldap_loginsmb).
'">';
868 print $ldap_loginsmb;
870 print
'<input class="maxwidth200 maxwidth150onsmartphone" maxsize="24" type="text" name="login" value="'.dol_escape_htmltag(
GETPOST(
'login',
'alphanohtml')).
'">';
874 $generated_password =
'';
875 if (empty($ldap_sid)) {
881 if (!empty($user->admin)) {
882 print
'<tr><td>'.$langs->trans(
"Administrator").
'</td>';
886 if (!empty($conf->multicompany->enabled) && !$user->entity) {
887 if (!empty($conf->use_javascript_ajax)) {
888 print
'<script type="text/javascript">
890 $("select[name=admin]").change(function() {
891 if ( $(this).val() == 0 ) {
892 $("input[name=superadmin]")
893 .prop("disabled", true)
894 .prop("checked", false);
895 $("select[name=entity]")
896 .prop("disabled", false);
898 $("input[name=superadmin]")
899 .prop("disabled", false);
902 $("input[name=superadmin]").change(function() {
903 if ( $(this).is(":checked") ) {
904 $("select[name=entity]")
905 .prop("disabled", true);
907 $("select[name=entity]")
908 .prop("disabled", false);
914 $checked = (
GETPOST(
'superadmin',
'int') ?
' checked' :
'');
915 $disabled = (
GETPOST(
'superadmin',
'int') ?
'' :
' disabled');
916 print
'<input type="checkbox" name="superadmin" id="superadmin" value="1"'.$checked.$disabled.
' /> <label for="superadmin">'.$langs->trans(
"SuperAdministrator").
'</span>';
918 print
"</td></tr>\n";
922 print
'<tr><td>'.$langs->trans(
"Gender").
'</td>';
924 $arraygender = array(
'man'=>$langs->trans(
"Genderman"),
'woman'=>$langs->trans(
"Genderwoman"),
'other'=>$langs->trans(
"Genderother"));
925 print
$form->selectarray(
'gender', $arraygender,
GETPOST(
'gender'), 1);
929 $defaultemployee =
'1';
931 print
'<td>'.$langs->trans(
'Employee').
'</td><td>';
932 print
'<input type="checkbox" name="employee" value="1"'.(GETPOST(
'employee') ==
'1' ?
' checked="checked"' : (($defaultemployee && !
GETPOSTISSET(
'login')) ?
' checked="checked"' :
'')).
'>';
937 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"HierarchicalResponsible").
'</td>';
939 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');
944 if (!empty($conf->expensereport->enabled)) {
945 print
'<tr><td class="titlefieldcreate">';
946 $text = $langs->trans(
"ForceUserExpenseValidator");
947 print
$form->textwithpicto($text, $langs->trans(
"ValidatorIsSupervisorByDefault"), 1,
'help');
950 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');
956 if (!empty($conf->holiday->enabled)) {
957 print
'<tr><td class="titlefieldcreate">';
958 $text = $langs->trans(
"ForceUserHolidayValidator");
959 print
$form->textwithpicto($text, $langs->trans(
"ValidatorIsSupervisorByDefault"), 1,
'help');
962 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');
968 print
'<tr><td>'.$langs->trans(
"ExternalUser").
' ?</td>';
970 print
$form->textwithpicto($langs->trans(
"Internal"), $langs->trans(
"InternalExternalDesc"), 1,
'help',
'', 0, 2);
974 print
'</table><hr><table class="border centpercent">';
978 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"RangeOfLoginValidity").
'</td>';
980 print
$form->selectDate($datestartvalidity,
'datestartvalidity', 0, 0, 1,
'formdatestartvalidity', 1, 1);
984 print
$form->selectDate($dateendvalidity,
'dateendvalidity', 0, 0, 1,
'formdateendvalidity', 1, 0);
989 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Password").
'</td>';
992 if (preg_match(
'/ldap/', $dolibarr_main_authentication)) {
993 $valuetoshow .= ($valuetoshow ?
', ' :
'').$langs->trans(
"PasswordOfUserInLDAP");
995 if (preg_match(
'/http/', $dolibarr_main_authentication)) {
996 $valuetoshow .= ($valuetoshow ?
', ' :
'').$langs->trans(
"HTTPBasicPassword");
998 if (preg_match(
'/dolibarr/', $dolibarr_main_authentication)) {
999 if (!empty($ldap_pass)) {
1000 $valuetoshow .= ($valuetoshow ?
', ' :
'').
'<input type="hidden" name="password" value="'.
dol_escape_htmltag($ldap_pass).
'">';
1001 $valuetoshow .= preg_replace(
'/./i',
'*', $ldap_pass);
1004 $valuetoshow .= ($valuetoshow ?
', ' :
'').
'<input maxsize="32" type="text" name="password" value="'.
dol_escape_htmltag($password).
'" autocomplete="new-password">';
1009 $parameters = array(
'valuetoshow' => $valuetoshow,
'password' => $password);
1010 $reshook = $hookmanager->executeHooks(
'printUserPasswordField',
$parameters, $object, $action);
1012 $valuetoshow = $hookmanager->resPrint;
1014 $valuetoshow .= $hookmanager->resPrint;
1020 if (!empty($conf->api->enabled)) {
1023 print
'<tr><td>'.$langs->trans(
"ApiKey").
'</td>';
1025 print
'<input class="minwidth300 widthcentpercentminusx" maxsize="32" type="text" id="api_key" name="api_key" value="'.GETPOST(
'api_key',
'alphanohtml').
'" autocomplete="off">';
1026 if (!empty($conf->use_javascript_ajax)) {
1027 print
' '.img_picto($langs->trans(
'Generate'),
'refresh',
'id="generate_api_key" class="linkobject"');
1033 print
'<input type="hidden" name="api_key" value="'.$generated_fake_api_key.
'">';
1037 print
'</table><hr><table class="border centpercent">';
1041 print
'<tr><td class="tdtop titlefieldcreate">'.$form->editfieldkey(
'Address',
'address',
'', $object, 0).
'</td>';
1042 print
'<td><textarea name="address" id="address" class="quatrevingtpercent" rows="3" wrap="soft">';
1043 print $object->address;
1044 print
'</textarea></td></tr>';
1047 print
'<tr><td>'.$form->editfieldkey(
'Zip',
'zipcode',
'', $object, 0).
'</td><td>';
1048 print $formcompany->select_ziptown($object->zip,
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6);
1052 print
'<tr><td>'.$form->editfieldkey(
'Town',
'town',
'', $object, 0).
'</td><td>';
1053 print $formcompany->select_ziptown($object->town,
'town', array(
'zipcode',
'selectcountry_id',
'state_id'));
1057 print
'<tr><td>'.$form->editfieldkey(
'Country',
'selectcountry_id',
'', $object, 0).
'</td><td class="maxwidthonsmartphone">';
1058 print
img_picto(
'',
'country',
'class="pictofixedwidth"');
1059 print
$form->select_country((
GETPOST(
'country_id') !=
'' ?
GETPOST(
'country_id') : $object->country_id));
1061 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1066 if (empty($conf->global->USER_DISABLE_STATE)) {
1067 print
'<tr><td>'.$form->editfieldkey(
'State',
'state_id',
'', $object, 0).
'</td><td class="maxwidthonsmartphone">';
1068 print
img_picto(
'',
'state',
'class="pictofixedwidth"');
1069 print $formcompany->select_state($object->state_id, $object->country_code,
'state_id');
1074 print
'<tr><td>'.$langs->trans(
"PhonePro").
'</td>';
1076 print
img_picto(
'',
'object_phoning',
'class="pictofixedwidth"');
1077 if (!empty($ldap_phone)) {
1078 print
'<input type="hidden" name="office_phone" value="'.dol_escape_htmltag($ldap_phone).
'">';
1081 print
'<input class="maxwidth200 widthcentpercentminusx" type="text" name="office_phone" value="'.dol_escape_htmltag(
GETPOST(
'office_phone',
'alphanohtml')).
'">';
1086 print
'<tr><td>'.$langs->trans(
"PhoneMobile").
'</td>';
1088 print
img_picto(
'',
'object_phoning_mobile',
'class="pictofixedwidth"');
1089 if (!empty($ldap_mobile)) {
1090 print
'<input type="hidden" name="user_mobile" value="'.dol_escape_htmltag($ldap_mobile).
'">';
1093 print
'<input class="maxwidth200 widthcentpercentminusx" type="text" name="user_mobile" value="'.dol_escape_htmltag(
GETPOST(
'user_mobile',
'alphanohtml')).
'">';
1098 print
'<tr><td>'.$langs->trans(
"Fax").
'</td>';
1100 print
img_picto(
'',
'object_phoning_fax',
'class="pictofixedwidth"');
1101 if (!empty($ldap_fax)) {
1102 print
'<input type="hidden" name="office_fax" value="'.dol_escape_htmltag($ldap_fax).
'">';
1105 print
'<input class="maxwidth200 widthcentpercentminusx" type="text" name="office_fax" value="'.dol_escape_htmltag(
GETPOST(
'office_fax',
'alphanohtml')).
'">';
1110 print
'<tr><td'.(!empty($conf->global->USER_MAIL_REQUIRED) ?
' class="fieldrequired"' :
'').
'>'.$langs->trans(
"EMail").
'</td>';
1112 print
img_picto(
'',
'object_email',
'class="pictofixedwidth"');
1113 if (!empty($ldap_mail)) {
1114 print
'<input type="hidden" name="email" value="'.dol_escape_htmltag($ldap_mail).
'">';
1117 print
'<input type="text" name="email" class="maxwidth500 widthcentpercentminusx" value="'.dol_escape_htmltag(
GETPOST(
'email',
'alphanohtml')).
'">';
1122 if (!empty($conf->socialnetworks->enabled)) {
1123 foreach ($socialnetworks as $key => $value) {
1124 if ($value[
'active']) {
1125 print
'<tr><td>'.$langs->trans($value[
'label']).
'</td>';
1127 if (!empty($value[
'icon'])) {
1128 print
'<span class="fa '.$value[
'icon'].
' pictofixedwidth"></span>';
1130 if (!empty($ldap_social[$key])) {
1131 print
'<input type="hidden" name="'.$key.
'" value="'.$ldap_social[$key].
'">';
1132 print $ldap_social[$key];
1134 print
'<input class="maxwidth200 widthcentpercentminusx" type="text" name="'.$key.
'" value="'.
GETPOST($key,
'alphanohtml').
'">';
1139 if (!empty($ldap_social[$key])) {
1140 print
'<input type="hidden" name="'.$key.
'" value="'.$ldap_social[$key].
'">';
1142 print
'<input type="hidden" name="'.$key.
'" value="'.
GETPOST($key,
'alphanohtml').
'">';
1149 if (!empty($conf->accounting->enabled)) {
1150 print
'<tr><td>'.$langs->trans(
"AccountancyCode").
'</td>';
1152 print
'<input type="text" class="maxwidthonsmartphone" name="accountancy_code" value="'.dol_escape_htmltag(
GETPOST(
'accountancy_code',
'alphanohtml')).
'">';
1158 print
'<tr><td>'.$langs->trans(
"ColorUser").
'</td>';
1160 print $formother->selectColor(
GETPOSTISSET(
'color') ?
GETPOST(
'color',
'alphanohtml') : $object->color,
'color',
null, 1,
'',
'hideifnotset');
1165 if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) {
1166 print
'<tr><td>'.$form->editfieldkey(
'Categories',
'usercats',
'', $object, 0).
'</td><td>';
1167 $cate_arbo =
$form->select_all_categories(
'user',
null,
'parent',
null,
null, 1);
1168 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'usercats', $cate_arbo,
GETPOST(
'usercats',
'array'), 0, 0,
'maxwdith300 widthcentpercentminusx', 0,
'90%');
1172 if (!empty($conf->global->MAIN_MULTILANGS)) {
1173 print
'<tr><td>'.$form->editfieldkey(
'DefaultLang',
'default_lang',
'', $object, 0,
'string',
'', 0, 0,
'id', $langs->trans(
"WarningNotLangOfInterface", $langs->transnoentitiesnoconv(
"UserGUISetup"))).
'</td>';
1174 print
'<td class="maxwidthonsmartphone">'.
"\n";
1175 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,
'maxwidth200onsmartphone widthcentpercentminusx');
1181 if (!empty($conf->multicompany->enabled) && is_object($mc)) {
1183 if (!method_exists($mc,
'formObjectOptions')) {
1184 if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && !$user->entity) {
1185 print
"<tr>".
'<td>'.$langs->trans(
"Entity").
'</td>';
1186 print
"<td>".$mc->select_entities($conf->entity);
1187 print
"</td></tr>\n";
1189 print
'<input type="hidden" name="entity" value="'.$conf->entity.
'" />';
1196 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
1199 print
'<tr><td class="tdtop">';
1200 print $langs->trans(
"Note");
1202 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1203 $doleditor =
new DolEditor(
'note',
GETPOSTISSET(
'note') ?
GETPOST(
'note',
'restricthtml') :
'',
'', 120,
'dolibarr_notes',
'',
false,
true,
getDolGlobalString(
'FCKEDITOR_ENABLE_SOCIETE'), ROWS_3,
'90%');
1204 $doleditor->Create();
1205 print
"</td></tr>\n";
1208 print
'<tr><td class="tdtop">'.$langs->trans(
"Signature").
'</td>';
1209 print
'<td class="wordbreak">';
1210 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1211 $doleditor =
new DolEditor(
'signature',
GETPOST(
'signature',
'restricthtml'),
'', 138,
'dolibarr_notes',
'In',
true,
true, empty($conf->global->FCKEDITOR_ENABLE_USERSIGN) ? 0 : 1, ROWS_4,
'90%');
1212 print $doleditor->Create(1);
1216 print
'</table><hr><table class="border centpercent">';
1222 if (!empty($conf->stock->enabled) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE_USER)) {
1223 print
'<tr><td>'.$langs->trans(
"DefaultWarehouse").
'</td><td>';
1224 print $formproduct->selectWarehouses($object->fk_warehouse,
'fk_warehouse',
'warehouseopen', 1);
1229 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"PostOrFunction").
'</td>';
1231 print
'<input class="maxwidth200 maxwidth150onsmartphone" type="text" name="job" value="'.dol_escape_htmltag(
GETPOST(
'job',
'alphanohtml')).
'">';
1234 if ((!empty($conf->salaries->enabled) && !empty($user->rights->salaries->read) && in_array($id, $childids))
1235 || (!empty($conf->salaries->enabled) && !empty($user->rights->salaries->readall))
1236 || (!empty($conf->hrm->enabled) && !empty($user->rights->hrm->employee->read))) {
1237 $langs->load(
"salaries");
1241 $text = $langs->trans(
"THM");
1242 print
$form->textwithpicto($text, $langs->trans(
"THMDescription"), 1,
'help',
'classthm');
1245 print
'<input size="8" type="text" name="thm" value="'.dol_escape_htmltag(
GETPOST(
'thm')).
'"> '.$langs->getCurrencySymbol($conf->currency);
1251 $text = $langs->trans(
"TJM");
1252 print
$form->textwithpicto($text, $langs->trans(
"TJMDescription"), 1,
'help',
'classtjm');
1255 print
'<input size="8" type="text" name="tjm" value="'.dol_escape_htmltag(
GETPOST(
'tjm')).
'"> '.$langs->getCurrencySymbol($conf->currency);
1260 print
'<tr><td>'.$langs->trans(
"Salary").
'</td>';
1262 print
img_picto(
'',
'salary',
'class="pictofixedwidth paddingright"').
'<input size="8" type="text" name="salary" value="'.
dol_escape_htmltag(
GETPOST(
'salary')).
'"> '.$langs->getCurrencySymbol($conf->currency);
1268 print
'<tr><td>'.$langs->trans(
"WeeklyHours").
'</td>';
1270 print
'<input size="8" type="text" name="weeklyhours" value="'.dol_escape_htmltag(
GETPOST(
'weeklyhours')).
'">';
1275 print
'<tr><td>'.$langs->trans(
"DateEmployment").
'</td>';
1277 print
$form->selectDate($dateemployment,
'dateemployment', 0, 0, 1,
'formdateemployment', 1, 1);
1281 print
$form->selectDate($dateemploymentend,
'dateemploymentend', 0, 0, 1,
'formdateemploymentend', 1, 0);
1286 print
'<tr><td>'.$langs->trans(
"DateOfBirth").
'</td>';
1288 print
$form->selectDate($dateofbirth,
'dateofbirth', 0, 0, 1,
'createuser', 1, 0, 0,
'', 0,
'',
'', 1,
'',
'',
'tzserver');
1296 print
$form->buttonsSaveCancel(
"CreateUser");
1302 $res = $object->fetch($id,
'',
'', 1);
1307 $res = $object->fetch_optionals();
1310 if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
1311 $object->getrights();
1312 if (empty($object->nb_rights) && $object->statut != 0 && empty($object->admin)) {
1319 if (!empty($conf->ldap->enabled) && !empty($object->ldap_sid)) {
1321 $result = $ldap->connect_bind();
1323 $userSearchFilter =
'('.$conf->global->LDAP_FILTER_CONNECTION.
'('.$ldap->getUserIdentifier().
'='.$object->login.
'))';
1324 $entries = $ldap->fetch($object->login, $userSearchFilter);
1329 $passDoNotExpire = 0;
1330 $userChangePassNextLogon = 0;
1335 if (count($ldap->uacf) > 0) {
1336 foreach ($ldap->uacf as $key => $statut) {
1337 if ($key == 65536) {
1338 $passDoNotExpire = 1;
1339 $statutUACF = $statut;
1344 $statutUACF =
"ACCOUNTDISABLE";
1347 if ($ldap->pwdlastset == 0) {
1348 $userChangePassNextLogon = 1;
1354 if ($mode ==
'employee') {
1355 $title = $langs->trans(
"Employee");
1356 $linkback =
'<a href="'.DOL_URL_ROOT.
'/hrm/employee/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
1358 $title = $langs->trans(
"User");
1361 if ($user->rights->user->user->lire || $user->admin) {
1362 $linkback =
'<a href="'.DOL_URL_ROOT.
'/user/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
1371 if ($action ==
'password') {
1372 print
$form->formconfirm($_SERVER[
'PHP_SELF'].
"?id=$object->id", $langs->trans(
"ReinitPassword"), $langs->trans(
"ConfirmReinitPassword", $object->login),
"confirm_password",
'', 0, 1);
1378 if ($action ==
'passwordsend') {
1379 print
$form->formconfirm($_SERVER[
'PHP_SELF'].
"?id=$object->id", $langs->trans(
"SendNewPassword"), $langs->trans(
"ConfirmSendNewPassword", $object->login),
"confirm_passwordsend",
'', 0, 1);
1385 if ($action ==
'disable') {
1386 print
$form->formconfirm($_SERVER[
'PHP_SELF'].
"?id=$object->id", $langs->trans(
"DisableAUser"), $langs->trans(
"ConfirmDisableUser", $object->login),
"confirm_disable",
'', 0, 1);
1392 if ($action ==
'enable') {
1393 print
$form->formconfirm($_SERVER[
'PHP_SELF'].
"?id=$object->id", $langs->trans(
"EnableAUser"), $langs->trans(
"ConfirmEnableUser", $object->login),
"confirm_enable",
'', 0, 1);
1399 if ($action ==
'delete') {
1400 print
$form->formconfirm($_SERVER[
'PHP_SELF'].
"?id=$object->id", $langs->trans(
"DeleteAUser"), $langs->trans(
"ConfirmDeleteUser", $object->login),
"confirm_delete",
'', 0, 1);
1406 if ($action !=
'edit') {
1409 $morehtmlref =
'<a href="'.DOL_URL_ROOT.
'/user/vcard.php?id='.$object->id.
'" class="refid">';
1410 $morehtmlref .=
img_picto($langs->trans(
"Download").
' '.$langs->trans(
"VCard"),
'vcard.png',
'class="valignmiddle marginleftonly paddingrightonly"');
1411 $morehtmlref .=
'</a>';
1413 dol_banner_tab($object,
'id', $linkback, $user->rights->user->user->lire || $user->admin,
'rowid',
'ref', $morehtmlref);
1415 print
'<div class="fichecenter">';
1416 print
'<div class="fichehalfleft">';
1418 print
'<div class="underbanner clearboth"></div>';
1419 print
'<table class="border tableforfield" width="100%">';
1422 print
'<tr><td class="titlefieldmiddle">'.$langs->trans(
"Login").
'</td>';
1423 if (!empty($object->ldap_sid) && $object->statut == 0) {
1424 print
'<td class="error">';
1425 print $langs->trans(
"LoginAccountDisableInDolibarr");
1430 if (property_exists($object,
'admin')) {
1431 if (!empty($conf->multicompany->enabled) && !empty($object->admin) && empty($object->entity)) {
1432 $addadmin .=
img_picto($langs->trans(
"SuperAdministratorDesc"),
"redstar",
'class="paddingleft"');
1433 } elseif (!empty($object->admin)) {
1434 $addadmin .=
img_picto($langs->trans(
"AdministratorDesc"),
"star",
'class="paddingleft"');
1444 $text = $langs->trans(
"Type");
1445 print
$form->textwithpicto($text, $langs->trans(
"InternalExternalDesc"));
1447 $type = $langs->trans(
"Internal");
1448 if ($object->socid > 0) {
1449 $type = $langs->trans(
"External");
1451 print
'<span class="badgeneutral">';
1453 if ($object->ldap_sid) {
1454 print
' ('.$langs->trans(
"DomainUser").
')';
1457 print
'</td></tr>'.
"\n";
1460 if ($object->ldap_sid) {
1461 print
'<tr><td>'.$langs->trans(
"Type").
'</td><td>';
1462 print $langs->trans(
"DomainUser", $ldap->domainFQDN);
1463 print
'</td></tr>'.
"\n";
1467 print
'<tr><td>'.$langs->trans(
"Employee").
'</td><td>';
1468 print
'<input type="checkbox" disabled name="employee" value="1"'.($object->employee ?
' checked="checked"' :
'').
'>';
1470 print
'</td></tr>'.
"\n";
1475 print
'<tr><td>'.$langs->trans(
"HierarchicalResponsible").
'</td>';
1477 if (empty($object->fk_user)) {
1478 print
'<span class="opacitymedium">'.$langs->trans(
"None").
'</span>';
1480 $huser =
new User($db);
1481 if ($object->fk_user > 0) {
1482 $huser->fetch($object->fk_user);
1483 print $huser->getNomUrl(1);
1485 print
'<span class="opacitymedium">'.$langs->trans(
"None").
'</span>';
1492 if (!empty($conf->expensereport->enabled)) {
1494 $text = $langs->trans(
"ForceUserExpenseValidator");
1495 print
$form->textwithpicto($text, $langs->trans(
"ValidatorIsSupervisorByDefault"), 1,
'help');
1498 if (!empty($object->fk_user_expense_validator)) {
1499 $evuser =
new User($db);
1500 $evuser->fetch($object->fk_user_expense_validator);
1501 print $evuser->getNomUrl(1);
1508 if (!empty($conf->holiday->enabled)) {
1510 $text = $langs->trans(
"ForceUserHolidayValidator");
1511 print
$form->textwithpicto($text, $langs->trans(
"ValidatorIsSupervisorByDefault"), 1,
'help');
1514 if (!empty($object->fk_user_holiday_validator)) {
1515 $hvuser =
new User($db);
1516 $hvuser->fetch($object->fk_user_holiday_validator);
1517 print $hvuser->getNomUrl(1);
1524 print
'<tr><td>'.$langs->trans(
"PostOrFunction").
'</td>';
1525 print
'<td>'.dol_escape_htmltag($object->job).
'</td>';
1529 print
'<tr><td>'.$langs->trans(
"WeeklyHours").
'</td>';
1536 if ((empty($user->socid) && in_array($id, $childids))
1537 || (!empty($conf->salaries->enabled) && !empty($user->rights->salaries->readall))
1538 || (!empty($conf->hrm->enabled) && !empty($user->rights->hrm->employee->read))) {
1539 $langs->load(
"salaries");
1542 print
'<tr><td>'.$langs->trans(
"Salary").
'</td>';
1544 print ($object->salary !=
'' ?
img_picto(
'',
'salary',
'class="pictofixedwidth paddingright"').
'<span class="amount">'.
price($object->salary,
'', $langs, 1, -1, -1, $conf->currency) :
'').
'</span>';
1550 $text = $langs->trans(
"THM");
1551 print
$form->textwithpicto($text, $langs->trans(
"THMDescription"), 1,
'help',
'classthm');
1554 print ($object->thm !=
'' ?
price($object->thm,
'', $langs, 1, -1, -1, $conf->currency) :
'');
1560 $text = $langs->trans(
"TJM");
1561 print
$form->textwithpicto($text, $langs->trans(
"TJMDescription"), 1,
'help',
'classtjm');
1564 print ($object->tjm !=
'' ?
price($object->tjm,
'', $langs, 1, -1, -1, $conf->currency) :
'');
1570 print
'<tr><td>'.$langs->trans(
"DateOfEmployment").
'</td>';
1572 if ($object->dateemployment) {
1573 print
'<span class="opacitymedium">'.$langs->trans(
"FromDate").
'</span> ';
1576 if ($object->dateemploymentend) {
1577 print
'<span class="opacitymedium"> - '.$langs->trans(
"To").
'</span> ';
1584 print
'<tr><td>'.$langs->trans(
"DateOfBirth").
'</td>';
1591 if (!empty($conf->stock->enabled) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE_USER)) {
1592 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/entrepot.class.php';
1593 print
'<tr><td>'.$langs->trans(
"DefaultWarehouse").
'</td><td>';
1594 if ($object->fk_warehouse > 0) {
1595 $warehousestatic =
new Entrepot($db);
1596 $warehousestatic->fetch($object->fk_warehouse);
1597 print $warehousestatic->getNomUrl(1);
1605 print
'<div class="fichehalfright">';
1607 print
'<div class="underbanner clearboth"></div>';
1609 print
'<table class="border tableforfield centpercent">';
1613 print
'<tr><td class="titlefield">'.$langs->trans(
"ColorUser").
'</td>';
1615 print $formother->showColor($object->color,
'');
1621 if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) {
1622 print
'<tr><td class="titlefield">'.$langs->trans(
"Categories").
'</td>';
1623 print
'<td colspan="3">';
1624 print
$form->showCategories($object->id, Categorie::TYPE_USER, 1);
1629 if (!empty($conf->global->MAIN_MULTILANGS)) {
1630 $langs->load(
"languages");
1631 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
1632 print
'<tr><td class="titlefield">';
1633 print
$form->textwithpicto($langs->trans(
"DefaultLang"), $langs->trans(
"WarningNotLangOfInterface", $langs->transnoentitiesnoconv(
"UserGUISetup")));
1637 $labellang = ($object->lang ? $langs->trans(
'Language_'.$object->lang) :
'');
1642 if (isset($conf->file->main_authentication) && preg_match(
'/openid/', $conf->file->main_authentication) && !empty($conf->global->MAIN_OPENIDURL_PERUSER)) {
1643 print
'<tr><td>'.$langs->trans(
"OpenIDURL").
'</td>';
1644 print
'<td>'.$object->openid.
'</td>';
1649 if (!empty($conf->multicompany->enabled) && is_object($mc)) {
1651 if (!method_exists($mc,
'formObjectOptions')) {
1652 if (!empty($conf->multicompany->enabled) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && !$user->entity) {
1653 print
'<tr><td>'.$langs->trans(
"Entity").
'</td><td>';
1654 if (empty($object->entity)) {
1655 print $langs->trans(
"AllEntities");
1657 $mc->getInfo($object->entity);
1660 print
"</td></tr>\n";
1666 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
1669 if (!empty($conf->societe->enabled)) {
1670 print
'<tr><td>'.$langs->trans(
"LinkToCompanyContact").
'</td>';
1673 if (isset($object->socid) && $object->socid > 0) {
1675 $societe->fetch($object->socid);
1676 if ($societe->id > 0) {
1677 $s .= $societe->getNomUrl(1,
'');
1680 $s .=
'<span class="opacitymedium hideonsmartphone">'.$langs->trans(
"ThisUserIsNot").
'</span>';
1682 if (!empty($object->contact_id)) {
1684 $contact->fetch($object->contact_id);
1685 if ($contact->id > 0) {
1686 if ($object->socid > 0 && $s) {
1691 $s .= $contact->getNomUrl(1,
'');
1700 if (!empty($conf->adherent->enabled)) {
1701 $langs->load(
"members");
1702 print
'<tr><td>'.$langs->trans(
"LinkedToDolibarrMember").
'</td>';
1704 if ($object->fk_member) {
1706 $adh->fetch($object->fk_member);
1707 $adh->ref = $adh->getFullname($langs);
1708 print $adh->getNomUrl(-1);
1710 print
'<span class="opacitymedium hideonsmartphone">'.$langs->trans(
"UserNotLinkedToMember").
'</span>';
1717 print
'<tr><td class="tdtop">'.$langs->trans(
'Signature').
'</td><td class="wordbreak">';
1719 print
"</td></tr>\n";
1724 print
'<div class="div-table-responsive-no-min">';
1725 print
'<table class="border tableforfield margintable centpercent">';
1726 print
'<tr class="liste_titre"><td class="liste_titre">';
1727 print
img_picto(
'',
'security',
'class="paddingleft pictofixedwidth"').$langs->trans(
"Credentials");
1729 print
'<td class="liste_titre"></td>';
1733 print
'<tr><td>'.$langs->trans(
"RangeOfLoginValidity").
'</td>';
1735 if ($object->datestartvalidity) {
1736 print
'<span class="opacitymedium">'.$langs->trans(
"FromDate").
'</span> ';
1739 if ($object->dateendvalidity) {
1740 print
'<span class="opacitymedium"> - '.$langs->trans(
"To").
'</span> ';
1747 print
'<tr><td class="titlefield">'.$langs->trans(
"Password").
'</td>';
1749 print
'<td class="wordbreak">';
1751 if (preg_match(
'/ldap/', $dolibarr_main_authentication)) {
1752 if (!empty($object->ldap_sid)) {
1753 if ($passDoNotExpire) {
1754 $valuetoshow .= ($valuetoshow ? (
' '.$langs->trans(
"or").
' ') :
'').$langs->trans(
"LdapUacf_".$statutUACF);
1755 } elseif ($userChangePassNextLogon) {
1756 $valuetoshow .= ($valuetoshow ? (
' '.$langs->trans(
"or").
' ') :
'').
'<span class="warning">'.$langs->trans(
"UserMustChangePassNextLogon", $ldap->domainFQDN).
'</span>';
1757 } elseif ($userDisabled) {
1758 $valuetoshow .= ($valuetoshow ? (
' '.$langs->trans(
"or").
' ') :
'').
'<span class="warning">'.$langs->trans(
"LdapUacf_".$statutUACF, $ldap->domainFQDN).
'</span>';
1760 $valuetoshow .= ($valuetoshow ? (
' '.$langs->trans(
"or").
' ') :
'').$langs->trans(
"PasswordOfUserInLDAP");
1763 $valuetoshow .= ($valuetoshow ? (
' '.$langs->trans(
"or").
' ') :
'').$langs->trans(
"PasswordOfUserInLDAP");
1766 if (preg_match(
'/http/', $dolibarr_main_authentication)) {
1767 $valuetoshow .= ($valuetoshow ? (
' '.$langs->trans(
"or").
' ') :
'').$langs->trans(
"HTTPBasicPassword");
1769 if (preg_match(
'/dolibarr/', $dolibarr_main_authentication)) {
1770 if ($object->pass) {
1771 $valuetoshow .= ($valuetoshow ? (
' '.$langs->trans(
"or").
' ') :
'');
1772 $valuetoshow .=
'<span class="opacitymedium">'.$langs->trans(
"Hidden").
'</span>';
1774 if ($user->admin && $user->id == $object->id) {
1775 $valuetoshow .= ($valuetoshow ? (
' '.$langs->trans(
"or").
' ') :
'');
1777 $valuetoshow .=
'<span class="opacitymedium">'.$langs->trans(
"Hidden").
'</span>';
1779 $valuetoshow .=
'<!-- Crypted into '.$object->pass_indatabase_crypted.
' -->';
1781 $valuetoshow .= ($valuetoshow ? (
' '.$langs->trans(
"or").
' ') :
'').
'<span class="opacitymedium">'.$langs->trans(
"Hidden").
'</span>';
1787 $parameters = array(
'valuetoshow' => $valuetoshow);
1788 $reshook = $hookmanager->executeHooks(
'printUserPasswordField',
$parameters, $object, $action);
1790 $valuetoshow = $hookmanager->resPrint;
1792 $valuetoshow .= $hookmanager->resPrint;
1800 if (!empty($conf->api->enabled) && ($user->id == $id || $user->admin || $user->rights->api->apikey->generate)) {
1801 print
'<tr><td>'.$langs->trans(
"ApiKey").
'</td>';
1803 if (!empty($object->api_key)) {
1804 print
'<span class="opacitymedium">';
1811 print
'<tr><td class="titlefield">'.$langs->trans(
"LastConnexion").
'</td>';
1813 if ($object->datepreviouslogin) {
1814 print
dol_print_date($object->datepreviouslogin,
"dayhour").
' <span class="opacitymedium">('.$langs->trans(
"Previous").
')</span>, ';
1816 if ($object->datelastlogin) {
1817 print
dol_print_date($object->datelastlogin,
"dayhour").
' <span class="opacitymedium">('.$langs->trans(
"Currently").
')</span>';
1822 print
'</table></div>';
1827 print
'<div style="clear:both"></div>';
1836 print
'<div class="tabsAction">';
1839 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons',
$parameters, $object, $action);
1840 if (empty($reshook)) {
1841 if (empty($user->socid)) {
1842 $canSendMail =
false;
1846 'class' =>
'classfortooltip'
1849 if (!empty($object->email)) {
1850 $langs->load(
"mails");
1851 $canSendMail =
true;
1853 $langs->load(
"mails");
1854 $params[
'attr'][
'title'] = $langs->trans(
'NoEMail');
1856 print
dolGetButtonAction($langs->trans(
'SendMail'),
'',
'default', $_SERVER[
'PHP_SELF'] .
'?id=' . $object->id .
'&action=presend&mode=init#formmailbeforetitle',
'', $canSendMail, $params);
1859 if ($caneditfield && (empty($conf->multicompany->enabled) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $object->entity == 1))) {
1863 'class' =>
'classfortooltip'
1866 if (!empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED)) {
1867 $params[
'attr'][
'title'] = $langs->trans(
'DisabledInMonoUserMode');
1868 print
dolGetButtonAction($langs->trans(
'Modify'),
'',
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false, $params);
1870 print
dolGetButtonAction($langs->trans(
'Modify'),
'',
'default', $_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=edit&token='.
newToken(),
'',
true, $params);
1872 } elseif ($caneditpassword && !$object->ldap_sid &&
1873 (empty($conf->multicompany->enabled) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $object->entity == 1))) {
1877 'class' =>
'classfortooltip'
1880 print
dolGetButtonAction($langs->trans(
'Modify'),
'',
'default', $_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=edit',
'',
true, $params);
1887 'class' =>
'classfortooltip'
1890 if ($conf->global->USER_PASSWORD_GENERATED !=
'none') {
1891 if ($object->statut == 0) {
1892 $params[
'attr'][
'title'] = $langs->trans(
'UserDisabled');
1893 print
dolGetButtonAction($langs->trans(
'ReinitPassword'),
'',
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false, $params);
1894 } elseif (($user->id != $id && $caneditpassword) && $object->login && !$object->ldap_sid &&
1895 ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $object->entity == 1))) {
1896 print
dolGetButtonAction($langs->trans(
'ReinitPassword'),
'',
'default', $_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=password&token='.
newToken(),
'',
true, $params);
1899 if ($object->statut == 0) {
1900 $params[
'attr'][
'title'] = $langs->trans(
'UserDisabled');
1901 print
dolGetButtonAction($langs->trans(
'SendNewPassword'),
'',
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false, $params);
1902 } elseif (($user->id != $id && $caneditpassword) && $object->login && !$object->ldap_sid &&
1903 ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $object->entity == 1))) {
1904 if ($object->email) {
1905 print
dolGetButtonAction($langs->trans(
'SendNewPassword'),
'',
'default', $_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=passwordsend&token='.
newToken(),
'',
true, $params);
1907 $params[
'attr'][
'title'] = $langs->trans(
'NoEMail');
1908 print
dolGetButtonAction($langs->trans(
'SendNewPassword'),
'',
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false, $params);
1917 'class' =>
'classfortooltip'
1920 if ($user->id <> $id && $candisableuser && $object->statut == 0 &&
1921 ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $object->entity == 1))) {
1922 print
dolGetButtonAction($langs->trans(
'Reactivate'),
'',
'default', $_SERVER[
'PHP_SELF'] .
'?id=' . $object->id .
'&action=enable&token='.newToken(),
'',
true, $params);
1925 if ($user->id <> $id && $candisableuser && $object->statut == 1 &&
1926 ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $object->entity == 1))) {
1927 print
dolGetButtonAction($langs->trans(
'DisableUser'),
'',
'default', $_SERVER[
'PHP_SELF'] .
'?id=' . $object->id .
'&action=disable&token='.newToken(),
'',
true, $params);
1929 if ($user->id == $id) {
1930 $params[
'attr'][
'title'] = $langs->trans(
'CantDisableYourself');
1931 print
dolGetButtonAction($langs->trans(
'DisableUser'),
'',
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false, $params);
1935 if ($user->id <> $id && $candisableuser &&
1936 ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $object->entity == 1))) {
1937 if ($user->admin || !$object->admin) {
1938 print
dolGetButtonAction($langs->trans(
'DeleteUser'),
'',
'default', $_SERVER[
'PHP_SELF'].
'?action=delete&token='.
newToken().
'&id='.$object->id,
'',
true, $params);
1940 $params[
'attr'][
'title'] = $langs->trans(
'MustBeAdminToDeleteOtherAdmin');
1941 print
dolGetButtonAction($langs->trans(
'DeleteUser'),
'',
'default', $_SERVER[
'PHP_SELF'].
'?action=delete&token='.
newToken().
'&id='.$object->id,
'',
false, $params);
1951 if (
GETPOST(
'modelselected')) {
1952 $action =
'presend';
1956 $modelmail =
'user';
1957 $defaulttopic =
'Information';
1958 $diroutput = $conf->user->dir_output;
1959 $trackid =
'use'.$object->id;
1961 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
1963 if ($action !=
'presend' && $action !=
'send') {
1968 if ($canreadgroup) {
1969 print
'<!-- Group section -->'.
"\n";
1977 $groupslist = $usergroup->listGroupsForUser($object->id,
false);
1979 if (!empty($groupslist)) {
1980 foreach ($groupslist as $groupforuser) {
1981 $exclude[] = $groupforuser->id;
1986 $parameters = array(
'caneditgroup' => $caneditgroup,
'groupslist' => $groupslist,
'exclude' => $exclude);
1987 $reshook = $hookmanager->executeHooks(
'formAddUserToGroup',
$parameters, $object, $action);
1988 print $hookmanager->resPrint;
1990 if (empty($reshook)) {
1991 if ($caneditgroup) {
1992 print
'<form action="'.$_SERVER[
'PHP_SELF'].
'?id='.$id.
'" method="POST">'.
"\n";
1993 print
'<input type="hidden" name="token" value="'.newToken().
'" />';
1994 print
'<input type="hidden" name="action" value="addgroup" />';
1995 print
'<input type="hidden" name="page_y" value="" />';
1998 print
'<table class="noborder centpercent">'.
"\n";
1999 print
'<tr class="liste_titre"><th class="liste_titre">'.$langs->trans(
"Groups").
'</th>'.
"\n";
2000 print
'<th class="liste_titre right">';
2001 if ($caneditgroup) {
2002 print
$form->select_dolgroups(
'',
'group', 1, $exclude, 0,
'',
'', $object->entity);
2004 print
'<input type="hidden" name="entity" value="'.$conf->entity.
'" />';
2005 print
'<input type="submit" class="button buttongen button-add reposition" value="'.$langs->trans(
"Add").
'" />';
2007 print
'</th></tr>'.
"\n";
2010 if (!empty($groupslist)) {
2011 foreach ($groupslist as $group) {
2012 print
'<tr class="oddeven">';
2014 if ($caneditgroup) {
2015 print $group->getNomUrl(1);
2017 print
img_object($langs->trans(
"ShowGroup"),
"group").
' '.$group->name;
2020 print
'<td class="right">';
2021 if ($caneditgroup) {
2022 print
'<a class="reposition" href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=removegroup&token='.
newToken().
'&group='.((int) $group->id).
'">';
2023 print
img_picto($langs->trans(
"RemoveFromGroup"),
'unlink');
2028 print
"</td></tr>\n";
2031 print
'<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans(
"None").
'</td></tr>';
2036 if ($caneditgroup) {
2048 if ($action ==
'edit' && ($canedituser || $caneditfield || $caneditpassword || ($user->id == $object->id))) {
2049 print
'<form action="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'" method="POST" name="updateuser" enctype="multipart/form-data">';
2050 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2051 print
'<input type="hidden" name="action" value="update">';
2052 print
'<input type="hidden" name="entity" value="'.$object->entity.
'">';
2056 print
'<table class="border centpercent">';
2059 if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) {
2060 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Ref").
'</td>';
2068 print
'<tr><td class="titlefieldcreate"><label for="civility_code">'.$langs->trans(
"UserTitle").
'</label></td><td colspan="3">';
2069 if ($caneditfield && !$object->ldap_sid) {
2070 print $formcompany->select_civility(
GETPOSTISSET(
"civility_code") ?
GETPOST(
"civility_code",
'aZ09') : $object->civility_code,
'civility_code');
2071 } elseif ($object->civility_code) {
2072 print $langs->trans(
"Civility".$object->civility_code);
2078 print
'<td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Lastname").
'</td>';
2080 if ($caneditfield && !$object->ldap_sid) {
2081 print
'<input class="minwidth100" type="text" class="flat" name="lastname" value="'.$object->lastname.
'">';
2083 print
'<input type="hidden" name="lastname" value="'.$object->lastname.
'">';
2084 print $object->lastname;
2090 print
"<tr>".
'<td>'.$langs->trans(
"Firstname").
'</td>';
2092 if ($caneditfield && !$object->ldap_sid) {
2093 print
'<input class="minwidth100" type="text" class="flat" name="firstname" value="'.$object->firstname.
'">';
2095 print
'<input type="hidden" name="firstname" value="'.$object->firstname.
'">';
2096 print $object->firstname;
2101 print
"<tr>".
'<td><span class="fieldrequired">'.$langs->trans(
"Login").
'</span></td>';
2103 if ($user->admin && !$object->ldap_sid) {
2104 print
'<input maxlength="50" type="text" class="flat" name="login" value="'.$object->login.
'">';
2106 print
'<input type="hidden" name="login" value="'.$object->login.
'">';
2107 print $object->login;
2113 print
'<tr><td>'.$langs->trans(
"Administrator").
'</td>';
2114 if ($object->socid > 0) {
2115 $langs->load(
"admin");
2117 print
'<input type="hidden" name="admin" value="'.$object->admin.
'">'.
yn($object->admin);
2118 print
' ('.$langs->trans(
"ExternalUser").
')';
2122 $nbAdmin = $user->getNbOfUsers(
'active',
'', 1);
2123 $nbSuperAdmin = $user->getNbOfUsers(
'active',
'superadmin', 1);
2127 && ($user->id != $object->id)
2129 (empty($conf->multicompany->enabled) && $nbAdmin >= 1)
2130 || (!empty($conf->multicompany->enabled) && (($object->entity > 0 || ($user->entity == 0 && $object->entity == 0)) || $nbSuperAdmin > 1))
2133 print
$form->selectyesno(
'admin', $object->admin, 1);
2135 if (!empty($conf->multicompany->enabled) && !$user->entity) {
2136 if ($conf->use_javascript_ajax) {
2137 print
'<script type="text/javascript">
2139 var admin = $("select[name=admin]").val();
2141 $("input[name=superadmin]")
2142 .prop("disabled", true)
2143 .prop("checked", false);
2145 if ($("input[name=superadmin]").is(":checked")) {
2146 $("select[name=entity]")
2147 .prop("disabled", true);
2149 $("select[name=admin]").change(function() {
2150 if ( $(this).val() == 0 ) {
2151 $("input[name=superadmin]")
2152 .prop("disabled", true)
2153 .prop("checked", false);
2154 $("select[name=entity]")
2155 .prop("disabled", false);
2157 $("input[name=superadmin]")
2158 .prop("disabled", false);
2161 $("input[name=superadmin]").change(function() {
2162 if ( $(this).is(":checked")) {
2163 $("select[name=entity]")
2164 .prop("disabled", true);
2166 $("select[name=entity]")
2167 .prop("disabled", false);
2174 $checked = (($object->admin && !$object->entity) ?
' checked' :
'');
2175 print
'<input type="checkbox" name="superadmin" id="superadmin" value="1"'.$checked.
' /> <label for="superadmin">'.$langs->trans(
"SuperAdministrator").
'</span>';
2178 $yn =
yn($object->admin);
2179 print
'<input type="hidden" name="admin" value="'.$object->admin.
'">';
2180 print
'<input type="hidden" name="superadmin" value="'.(empty($object->entity) ? 1 : 0).
'">';
2181 if (!empty($conf->multicompany->enabled) && empty($object->entity)) {
2182 print
$form->textwithpicto($yn, $langs->trans(
"DontDowngradeSuperAdmin"), 1,
'warning');
2191 print
'<tr><td>'.$langs->trans(
"Gender").
'</td>';
2193 $arraygender = array(
'man'=>$langs->trans(
"Genderman"),
'woman'=>$langs->trans(
"Genderwoman"),
'other'=>$langs->trans(
"Genderother"));
2194 if ($caneditfield) {
2197 print $arraygender[$object->gender];
2203 print
'<td>'.$form->editfieldkey(
'Employee',
'employee',
'', $object, 0).
'</td><td>';
2204 if ($caneditfield) {
2205 print
'<input type="checkbox" name="employee" value="1"'.($object->employee ?
' checked="checked"' :
'').
'>';
2208 print
'<input type="checkbox" name="employee" disabled value="1"'.($object->employee ?
' checked="checked"' :
'').
'>';
2218 print
'<tr><td class="titlefield">'.$langs->trans(
"HierarchicalResponsible").
'</td>';
2220 if ($caneditfield) {
2221 print
img_picto(
'',
'user').$form->select_dolusers($object->fk_user,
'fk_user', 1, array($object->id), 0,
'', 0, $object->entity, 0, 0,
'', 0,
'',
'widthcentpercentminusx maxwidth300');
2223 print
'<input type="hidden" name="fk_user" value="'.$object->fk_user.
'">';
2224 $huser =
new User($db);
2225 $huser->fetch($object->fk_user);
2226 print $huser->getNomUrl(1);
2232 if (!empty($conf->expensereport->enabled)) {
2233 print
'<tr><td class="titlefield">';
2234 $text = $langs->trans(
"ForceUserExpenseValidator");
2235 print
$form->textwithpicto($text, $langs->trans(
"ValidatorIsSupervisorByDefault"), 1,
'help');
2238 if ($caneditfield) {
2239 print
img_picto(
'',
'user').$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');
2241 print
'<input type="hidden" name="fk_user_expense_validator" value="'.$object->fk_user_expense_validator.
'">';
2242 $evuser =
new User($db);
2243 $evuser->fetch($object->fk_user_expense_validator);
2244 print $evuser->getNomUrl(1);
2251 if (!empty($conf->holiday->enabled)) {
2252 print
'<tr><td class="titlefield">';
2253 $text = $langs->trans(
"ForceUserHolidayValidator");
2254 print
$form->textwithpicto($text, $langs->trans(
"ValidatorIsSupervisorByDefault"), 1,
'help');
2257 if ($caneditfield) {
2258 print
img_picto(
'',
'user').$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');
2260 print
'<input type="hidden" name="fk_user_holiday_validator" value="'.$object->fk_user_holiday_validator.
'">';
2261 $hvuser =
new User($db);
2262 $hvuser->fetch($object->fk_user_holiday_validator);
2263 print $hvuser->getNomUrl(1);
2270 print
'<tr><td>'.$langs->trans(
"ExternalUser").
' ?</td>';
2272 if ($user->id == $object->id || !$user->admin) {
2274 $type = $langs->trans(
"Internal");
2275 if ($object->socid) {
2276 $type = $langs->trans(
"External");
2278 print
$form->textwithpicto($type, $langs->trans(
"InternalExternalDesc"));
2279 if ($object->ldap_sid) {
2280 print
' ('.$langs->trans(
"DomainUser").
')';
2285 if ($object->contact_id) {
2286 $type = $object->contact_id;
2289 if ($object->socid > 0 && !($object->contact_id > 0)) {
2290 print
img_picto(
'',
'company').$form->select_company($object->socid,
'socid',
'',
' ');
2291 print
img_picto(
'',
'contact').$form->selectcontacts(0, 0,
'contactid', 1,
'',
'', 1,
'',
false, 1);
2292 if ($object->ldap_sid) {
2293 print
' ('.$langs->trans(
"DomainUser").
')';
2295 } elseif ($object->socid > 0 && $object->contact_id > 0) {
2296 print
img_picto(
'',
'company').$form->select_company($object->socid,
'socid',
'',
' ');
2297 print
img_picto(
'',
'contact').$form->selectcontacts(0, $object->contact_id,
'contactid', 1,
'',
'', 1,
'',
false, 1);
2298 if ($object->ldap_sid) {
2299 print
' ('.$langs->trans(
"DomainUser").
')';
2301 } elseif (!($object->socid > 0) && $object->contact_id > 0) {
2302 print
img_picto(
'',
'company').$form->select_company(0,
'socid',
'',
' ');
2303 print
img_picto(
'',
'contact').$form->selectcontacts(0, $object->contact_id,
'contactid', 1,
'',
'', 1,
'',
false, 1);
2304 if ($object->ldap_sid) {
2305 print
' ('.$langs->trans(
"DomainUser").
')';
2308 print
img_picto(
'',
'company').$form->select_company(0,
'socid',
'',
' ');
2309 print
img_picto(
'',
'contact').$form->selectcontacts(0, 0,
'contactid', 1,
'',
'', 1,
'',
false, 1);
2315 print
'</table><hr><table class="border centpercent">';
2319 print
'<tr><td>'.$langs->trans(
"RangeOfLoginValidity").
'</td>';
2321 if ($caneditfield) {
2322 print
$form->selectDate($datestartvalidity ? $datestartvalidity : $object->datestartvalidity,
'datestartvalidity', 0, 0, 1,
'formdatestartvalidity', 1, 1, 0,
'',
'',
'',
'', 1,
'',
'');
2332 if ($caneditfield) {
2333 print
$form->selectDate($dateendvalidity ? $datendevalidity : $object->dateendvalidity,
'dateendvalidity', 0, 0, 1,
'formdateendvalidity', 1, 0, 0,
'',
'',
'',
'', 1,
'',
'');
2341 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Password").
'</td>';
2344 if (preg_match(
'/ldap/', $dolibarr_main_authentication)) {
2345 $valuetoshow .= ($valuetoshow ? (
' '.$langs->trans(
"or").
' ') :
'').$langs->trans(
"PasswordOfUserInLDAP");
2347 if (preg_match(
'/http/', $dolibarr_main_authentication)) {
2348 $valuetoshow .= ($valuetoshow ? (
' '.$langs->trans(
"or").
' ') :
'').
$form->textwithpicto($text, $langs->trans(
"DolibarrInHttpAuthenticationSoPasswordUseless", $dolibarr_main_authentication), 1,
'warning');
2350 if (preg_match(
'/dolibarr/', $dolibarr_main_authentication)) {
2351 if ($caneditpassword) {
2352 $valuetoshow .= ($valuetoshow ? (
' '.$langs->trans(
"or").
' ') :
'').
'<input maxlength="128" type="password" class="flat" name="password" value="'.
dol_escape_htmltag($object->pass).
'" autocomplete="new-password">';
2354 $valuetoshow .= ($valuetoshow ? (
' '.$langs->trans(
"or").
' ') :
'').preg_replace(
'/./i',
'*', $object->pass);
2359 $parameters = array(
'valuetoshow' => $valuetoshow,
'caneditpassword' => $caneditpassword);
2360 $reshook = $hookmanager->executeHooks(
'printUserPasswordField',
$parameters, $object, $action);
2362 $valuetoshow = $hookmanager->resPrint;
2364 $valuetoshow .= $hookmanager->resPrint;
2368 print
"</td></tr>\n";
2371 if (!empty($conf->api->enabled) && ($user->id == $id || $user->admin || $user->rights->api->apikey->generate)) {
2372 print
'<tr><td>'.$langs->trans(
"ApiKey").
'</td>';
2374 print
'<input class="minwidth300" maxsize="32" type="text" id="api_key" name="api_key" value="'.$object->api_key.
'" autocomplete="off">';
2375 if (!empty($conf->use_javascript_ajax)) {
2376 print
' '.img_picto($langs->trans(
'Generate'),
'refresh',
'id="generate_api_key" class="linkobject"');
2382 if (isset($conf->file->main_authentication) && preg_match(
'/openid/', $conf->file->main_authentication) && !empty($conf->global->MAIN_OPENIDURL_PERUSER)) {
2383 print
"<tr>".
'<td>'.$langs->trans(
"OpenIDURL").
'</td>';
2385 if ($caneditfield) {
2386 print
'<input class="minwidth100" type="url" name="openid" class="flat" value="'.$object->openid.
'">';
2388 print
'<input type="hidden" name="openid" value="'.$object->openid.
'">';
2389 print $object->openid;
2394 print
'</table><hr><table class="border centpercent">';
2398 print
'<tr><td class="tdtop titlefieldcreate">'.$form->editfieldkey(
'Address',
'address',
'', $object, 0).
'</td>';
2400 if ($caneditfield) {
2401 print
'<textarea name="address" id="address" class="quatrevingtpercent" rows="3" wrap="soft">';
2403 print $object->address;
2404 if ($caneditfield) {
2405 print
'</textarea>';
2410 print
'<tr><td>'.$form->editfieldkey(
'Zip',
'zipcode',
'', $object, 0).
'</td><td>';
2411 if ($caneditfield) {
2412 print $formcompany->select_ziptown($object->zip,
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6);
2419 print
'<tr><td>'.$form->editfieldkey(
'Town',
'town',
'', $object, 0).
'</td><td>';
2420 if ($caneditfield) {
2421 print $formcompany->select_ziptown($object->town,
'town', array(
'zipcode',
'selectcountry_id',
'state_id'));
2423 print $object->town;
2428 print
'<tr><td>'.$form->editfieldkey(
'Country',
'selectcounty_id',
'', $object, 0).
'</td><td>';
2429 if ($caneditfield) {
2430 print
$form->select_country((
GETPOST(
'country_id') !=
'' ?
GETPOST(
'country_id') : $object->country_id),
'country_id');
2432 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
2435 $countrylabel =
getCountry($object->country_id,
'0');
2436 print $countrylabel;
2441 if (empty($conf->global->USER_DISABLE_STATE)) {
2442 print
'<tr><td class="tdoverflow">'.$form->editfieldkey(
'State',
'state_id',
'', $object, 0).
'</td><td>';
2443 if ($caneditfield) {
2444 print
img_picto(
'',
'state',
'class="pictofixedwidth"');
2445 print $formcompany->select_state($object->state_id, $object->country_code,
'state_id');
2447 print $object->state_label;
2453 print
"<tr>".
'<td>'.$langs->trans(
"PhonePro").
'</td>';
2455 print
img_picto(
'',
'phoning',
'class="pictofixedwidth"');
2456 if ($caneditfield && empty($object->ldap_sid)) {
2457 print
'<input type="text" name="office_phone" class="flat maxwidth200" value="'.$object->office_phone.
'">';
2459 print
'<input type="hidden" name="office_phone" value="'.$object->office_phone.
'">';
2460 print $object->office_phone;
2465 print
"<tr>".
'<td>'.$langs->trans(
"PhoneMobile").
'</td>';
2467 print
img_picto(
'',
'phoning_mobile',
'class="pictofixedwidth"');
2468 if ($caneditfield && empty($object->ldap_sid)) {
2469 print
'<input type="text" name="user_mobile" class="flat maxwidth200" value="'.$object->user_mobile.
'">';
2471 print
'<input type="hidden" name="user_mobile" value="'.$object->user_mobile.
'">';
2472 print $object->user_mobile;
2477 print
"<tr>".
'<td>'.$langs->trans(
"Fax").
'</td>';
2479 print
img_picto(
'',
'phoning_fax',
'class="pictofixedwidth"');
2480 if ($caneditfield && empty($object->ldap_sid)) {
2481 print
'<input type="text" name="office_fax" class="flat maxwidth200" value="'.$object->office_fax.
'">';
2483 print
'<input type="hidden" name="office_fax" value="'.$object->office_fax.
'">';
2484 print $object->office_fax;
2489 print
"<tr>".
'<td'.(!empty($conf->global->USER_MAIL_REQUIRED) ?
' class="fieldrequired"' :
'').
'>'.$langs->trans(
"EMail").
'</td>';
2491 print
img_picto(
'',
'object_email',
'class="pictofixedwidth"');
2492 if ($caneditfield && empty($object->ldap_sid)) {
2493 print
'<input class="minwidth100 maxwidth500 widthcentpercentminusx" type="text" name="email" class="flat" value="'.$object->email.
'">';
2495 print
'<input type="hidden" name="email" value="'.$object->email.
'">';
2496 print $object->email;
2500 if (!empty($conf->socialnetworks->enabled)) {
2501 foreach ($socialnetworks as $key => $value) {
2502 if ($value[
'active']) {
2503 print
'<tr><td>'.$langs->trans($value[
'label']).
'</td>';
2505 if (!empty($value[
'icon'])) {
2506 print
'<span class="fa '.$value[
'icon'].
' pictofixedwidth"></span>';
2508 if ($caneditfield && empty($object->ldap_sid)) {
2509 print
'<input type="text" name="'.$key.
'" class="flat maxwidth200" value="'.(isset($object->socialnetworks[$key])?$object->socialnetworks[$key]:
'').
'">';
2511 print
'<input type="hidden" name="'.$key.
'" value="'.$object->socialnetworks[$key].
'">';
2512 print $object->socialnetworks[$key];
2517 print
'<input type="hidden" name="'.$key.
'" value="'.(isset($object->socialnetworks[$key])?$object->socialnetworks[$key]:
'').
'">';
2522 print
'</table><hr><table class="border centpercent">';
2525 if (!empty($conf->stock->enabled) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE_USER)) {
2526 print
'<tr><td class="titlefield">'.$langs->trans(
"DefaultWarehouse").
'</td><td>';
2527 print $formproduct->selectWarehouses($object->fk_warehouse,
'fk_warehouse',
'warehouseopen', 1);
2528 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>';
2533 if (!empty($conf->accounting->enabled)) {
2535 print
'<td class="titlefieldcreate">'.$langs->trans(
"AccountancyCode").
'</td>';
2537 if ($caneditfield) {
2538 print
'<input type="text" class="flat maxwidth300" name="accountancy_code" value="'.$object->accountancy_code.
'">';
2540 print
'<input type="hidden" name="accountancy_code" value="'.$object->accountancy_code.
'">';
2541 print $object->accountancy_code;
2549 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ColorUser").
'</td>';
2551 if ($caneditfield) {
2552 print $formother->selectColor(
GETPOSTISSET(
'color') ?
GETPOST(
'color',
'alphanohtml') : $object->color,
'color',
null, 1,
'',
'hideifnotset');
2554 print $formother->showColor($object->color,
'');
2561 print
'<td class="titlefieldcreate">'.$langs->trans(
"Photo").
'</td>';
2563 print
$form->showphoto(
'userphoto', $object, 60, 0, $caneditfield,
'photowithmargin',
'small', 1, 0,
'user', 1);
2568 if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) {
2569 print
'<tr><td>'.$form->editfieldkey(
'Categories',
'usercats',
'', $object, 0).
'</td>';
2571 print
img_picto(
'',
'category',
'class="pictofixedwidth"');
2572 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_USER,
null,
null,
null,
null, 1);
2574 $cats = $c->containing($object->id, Categorie::TYPE_USER);
2575 foreach ($cats as $cat) {
2576 $arrayselected[] = $cat->id;
2578 if ($caneditfield) {
2579 print
$form->multiselectarray(
'usercats', $cate_arbo, $arrayselected,
'', 0,
'', 0,
'90%');
2581 print
$form->showCategories($object->id, Categorie::TYPE_USER, 1);
2587 if (!empty($conf->global->MAIN_MULTILANGS)) {
2588 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";
2589 print
img_picto(
'',
'language',
'class="pictofixedwidth"').$formadmin->select_language($object->lang,
'default_lang', 0,
null,
'1', 0, 0,
'widthcentpercentminusx maxwidth300');
2595 print
'<tr><td>'.$langs->trans(
"Status").
'</td>';
2597 print $object->getLibStatut(4);
2601 if (!empty($conf->societe->enabled)) {
2602 print
'<tr><td>'.$langs->trans(
"LinkToCompanyContact").
'</td>';
2604 if ($object->socid > 0) {
2606 $societe->fetch($object->socid);
2607 print $societe->getNomUrl(1,
'');
2608 if ($object->contact_id) {
2610 $contact->fetch($object->contact_id);
2611 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>';
2614 print
'<span class="opacitymedium hideonsmartphone">'.$langs->trans(
"ThisUserIsNot").
'</span>';
2616 print
' <span class="opacitymedium hideonsmartphone">('.$langs->trans(
"UseTypeFieldToChange").
')</span>';
2622 if (!empty($conf->adherent->enabled)) {
2623 $langs->load(
"members");
2624 print
'<tr><td>'.$langs->trans(
"LinkedToDolibarrMember").
'</td>';
2626 if ($object->fk_member) {
2628 $adh->fetch($object->fk_member);
2629 $adh->ref = $adh->login;
2630 print $adh->getNomUrl(1);
2632 print
'<span class="opacitymedium hideonsmartphone">'.$langs->trans(
"UserNotLinkedToMember").
'</span>';
2640 if (!empty($conf->multicompany->enabled) && is_object($mc)) {
2642 if (!method_exists($mc,
'formObjectOptions')) {
2643 if (empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && !$user->entity) {
2644 print
"<tr>".
'<td>'.$langs->trans(
"Entity").
'</td>';
2645 print
"<td>".$mc->select_entities($object->entity,
'entity',
'', 0, 1,
false,
false, 1);
2646 print
"</td></tr>\n";
2648 print
'<input type="hidden" name="entity" value="'.$conf->entity.
'" />';
2656 $reshook = $hookmanager->executeHooks(
'formObjectOptions',
$parameters, $object, $action);
2657 print $hookmanager->resPrint;
2658 if (empty($reshook)) {
2659 if ($caneditfield) {
2660 print $object->showOptionals($extrafields,
'edit');
2662 print $object->showOptionals($extrafields,
'view');
2667 print
'<tr><td class="tdtop">'.$langs->trans(
"Signature").
'</td>';
2669 if ($caneditfield) {
2670 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
2671 $doleditor =
new DolEditor(
'signature', $object->signature,
'', 138,
'dolibarr_notes',
'In',
false,
true, empty($conf->global->FCKEDITOR_ENABLE_USERSIGN) ? 0 : 1, ROWS_4,
'90%');
2672 print $doleditor->Create(1);
2684 print
'<table class="border centpercent">';
2690 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"PostOrFunction").
'</td>';
2692 if ($caneditfield) {
2693 print
'<input type="text" class="minwidth300 maxwidth500" name="job" value="'.dol_escape_htmltag($object->job).
'">';
2695 print
'<input type="hidden" name="job" value="'.dol_escape_htmltag($object->job).
'">';
2701 print
'<tr><td>'.$langs->trans(
"WeeklyHours").
'</td>';
2703 if ($caneditfield) {
2704 print
'<input size="8" type="text" name="weeklyhours" value="'.price2num(
GETPOST(
'weeklyhours') ?
GETPOST(
'weeklyhours') : $object->weeklyhours).
'">';
2712 if ((empty($user->socid) && in_array($id, $childids))
2713 || (!empty($conf->salaries->enabled) && !empty($user->rights->salaries->readall))
2714 || (!empty($conf->hrm->enabled) && !empty($user->rights->hrm->employee->read))) {
2715 $langs->load(
"salaries");
2718 print
'<tr><td>'.$langs->trans(
"Salary").
'</td>';
2720 print
img_picto(
'',
'salary',
'class="pictofixedwidth paddingright"').
'<input size="8" type="text" name="salary" value="'.
price2num(
GETPOST(
'salary') ?
GETPOST(
'salary') : $object->salary).
'">';
2726 $text = $langs->trans(
"THM");
2727 print
$form->textwithpicto($text, $langs->trans(
"THMDescription"), 1,
'help',
'classthm');
2730 if ($caneditfield) {
2731 print
'<input size="8" type="text" name="thm" value="'.price2num(
GETPOST(
'thm') ?
GETPOST(
'thm') : $object->thm).
'">';
2733 print ($object->thm !=
'' ?
price($object->thm,
'', $langs, 1, -1, -1, $conf->currency) :
'');
2740 $text = $langs->trans(
"TJM");
2741 print
$form->textwithpicto($text, $langs->trans(
"TJMDescription"), 1,
'help',
'classthm');
2744 if ($caneditfield) {
2745 print
'<input size="8" type="text" name="tjm" value="'.price2num(
GETPOST(
'tjm') ?
GETPOST(
'tjm') : $object->tjm).
'">';
2747 print ($object->tjm !=
'' ?
price($object->tjm,
'', $langs, 1, -1, -1, $conf->currency) :
'');
2754 print
'<tr><td>'.$langs->trans(
"DateEmployment").
'</td>';
2756 if ($caneditfield) {
2757 print
$form->selectDate($dateemployment ? $dateemployment : $object->dateemployment,
'dateemployment', 0, 0, 1,
'formdateemployment', 1, 1);
2762 if ($dateemployment && $dateemploymentend) {
2766 if ($caneditfield) {
2767 print
$form->selectDate($dateemploymentend ? $dateemploymentend : $object->dateemploymentend,
'dateemploymentend', 0, 0, 1,
'formdateemploymentend', 1, 0);
2775 print
'<tr><td>'.$langs->trans(
"DateOfBirth").
'</td>';
2777 if ($caneditfield) {
2778 echo
$form->selectDate($dateofbirth ? $dateofbirth : $object->birth,
'dateofbirth', 0, 0, 1,
'updateuser', 1, 0, 0,
'',
'',
'',
'', 1,
'',
'',
'tzserver');
2789 print
'<div class="center">';
2790 print
'<input value="'.$langs->trans(
"Save").
'" class="button button-save" type="submit" name="save">';
2791 print
' ';
2792 print
'<input value="'.$langs->trans(
"Cancel").
'" class="button button-cancel" type="submit" name="cancel">';
2798 if ($action !=
'edit' && $action !=
'presend') {
2799 print
'<div class="fichecenter"><div class="fichehalfleft">';
2804 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".$object->id;
2805 $genallowed = $user->rights->user->user->lire;
2806 $delallowed = $user->rights->user->user->creer;
2808 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);
2809 $somethingshown = $formfile->numoffiles;
2812 $linktoelem =
$form->showLinkToObjectBlock($object,
null,
null);
2813 $somethingshown =
$form->showLinkedObjectBlock($object, $linktoelem);
2815 print
'</div><div class="fichehalfright">';
2818 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
2820 $somethingshown =
$formactions->showactions($object,
'user', $socid, 1);
2822 print
'</div></div>';
2825 if (!empty($conf->ldap->enabled) && !empty($object->ldap_sid)) {
2831 if (!empty($conf->api->enabled) && !empty($conf->use_javascript_ajax)) {
2832 print
"\n".
'<script type="text/javascript">';
2833 print
'$(document).ready(function () {
2834 $("#generate_api_key").click(function() {
2835 $.get( "'.DOL_URL_ROOT.
'/core/ajax/security.php", {
2836 action: \'getrandompassword\',
2840 $("#api_key").val(token);