39 require
'../main.inc.php';
40 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
41 require_once DOL_DOCUMENT_ROOT.
'/user/class/usergroup.class.php';
42 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
43 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
44 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
45 require_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
46 require_once DOL_DOCUMENT_ROOT.
'/core/lib/usergroups.lib.php';
47 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
48 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
49 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
50 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
51 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
52 require_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
54 require_once DOL_DOCUMENT_ROOT.
'/core/class/ldap.class.php';
57 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
60 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
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';
81 $dateemployment =
dol_mktime(0, 0, 0,
GETPOST(
'dateemploymentmonth',
'int'),
GETPOST(
'dateemploymentday',
'int'),
GETPOST(
'dateemploymentyear',
'int'));
82 $dateemploymentend =
dol_mktime(0, 0, 0,
GETPOST(
'dateemploymentendmonth',
'int'),
GETPOST(
'dateemploymentendday',
'int'),
GETPOST(
'dateemploymentendyear',
'int'));
83 $datestartvalidity =
dol_mktime(0, 0, 0,
GETPOST(
'datestartvaliditymonth',
'int'),
GETPOST(
'datestartvalidityday',
'int'),
GETPOST(
'datestartvalidityyear',
'int'));
84 $dateendvalidity =
dol_mktime(0, 0, 0,
GETPOST(
'dateendvaliditymonth',
'int'),
GETPOST(
'dateendvalidityday',
'int'),
GETPOST(
'dateendvalidityyear',
'int'));
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);
110 if ($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;
123 if (!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"));
128 if ($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);
151 if (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) {
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');
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');
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'));
354 $langs->load(
"errors");
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');
433 $object->ref_employee =
GETPOST(
"ref_employee",
'alphanohtml');
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');
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;
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)) {
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');
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"));
675 if ((($action ==
'confirm_password' && $confirm ==
'yes')
676 || ($action ==
'confirm_passwordsend' && $confirm ==
'yes')) && $caneditpassword
680 $newpassword = $object->setPassword($user,
'');
681 if ($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';
780 if ($object->id > 0) {
781 $person_name = !empty($object->firstname) ? $object->lastname.
", ".$object->firstname : $object->lastname;
782 $title = $person_name.
" - ".$langs->trans(
'Card');
784 $title = $langs->trans(
"NewUser");
791 if ($action ==
'create' || $action ==
'adduserldap') {
794 print
'<span class="opacitymedium">'.$langs->trans(
"CreateInternalUserDesc").
"</span><br>\n";
801 $result = $ldap->connect_bind();
803 $required_fields = array(
804 $conf->global->LDAP_KEY_USERS,
805 $conf->global->LDAP_FIELD_FULLNAME,
806 $conf->global->LDAP_FIELD_NAME,
807 $conf->global->LDAP_FIELD_FIRSTNAME,
808 $conf->global->LDAP_FIELD_LOGIN,
809 $conf->global->LDAP_FIELD_LOGIN_SAMBA,
810 $conf->global->LDAP_FIELD_PASSWORD,
811 $conf->global->LDAP_FIELD_PASSWORD_CRYPTED,
812 $conf->global->LDAP_FIELD_PHONE,
813 $conf->global->LDAP_FIELD_FAX,
814 $conf->global->LDAP_FIELD_MOBILE,
815 $conf->global->LDAP_FIELD_SKYPE,
816 $conf->global->LDAP_FIELD_MAIL,
817 $conf->global->LDAP_FIELD_TITLE,
818 $conf->global->LDAP_FIELD_DESCRIPTION,
819 $conf->global->LDAP_FIELD_SID
823 $required_fields = array_unique(array_values(array_filter($required_fields,
"dol_validElement")));
826 $ldapusers = $ldap->getRecords(
'*', $conf->global->LDAP_USER_DN, $conf->global->LDAP_KEY_USERS, $required_fields, 1);
828 if (is_array($ldapusers)) {
830 foreach ($ldapusers as $key => $ldapuser) {
833 foreach ($required_fields as $value) {
834 if ($value === $conf->global->LDAP_FIELD_PASSWORD || $value === $conf->global->LDAP_FIELD_PASSWORD_CRYPTED) {
835 $label .= $value.
"=******* ";
837 $label .= $value.
"=".$ldapuser[$value].
" ";
840 $liste[$key] = $label;
850 print
"\n\n<!-- Form liste LDAP debut -->\n";
852 print
'<form name="add_user_ldap" action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
853 print
'<input type="hidden" name="token" value="'.newToken().
'">';
854 print
'<table class="border centpercent"><tr>';
855 print
'<td width="160">';
856 print $langs->trans(
"LDAPUsers");
859 print
'<input type="hidden" name="action" value="adduserldap">';
860 if (is_array($liste) && count($liste)) {
861 print
$form->selectarray(
'users', $liste,
'', 1, 0, 0,
'', 0, 0, 0,
'',
'maxwidth500');
864 print
'</td><td class="center">';
865 print
'<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans(
'Get')).
'"'.(count($liste) ?
'' :
' disabled').
'>';
866 print
'</td></tr></table>';
869 print
"\n<!-- Form liste LDAP fin -->\n\n";
874 print
'<form action="'.$_SERVER[
'PHP_SELF'].
'" method="POST" name="createuser">';
875 print
'<input type="hidden" name="token" value="'.newToken().
'">';
876 print
'<input type="hidden" name="action" value="add">';
877 if (!empty($ldap_sid)) {
878 print
'<input type="hidden" name="ldap_sid" value="'.dol_escape_htmltag($ldap_sid).
'">';
880 print
'<input type="hidden" name="entity" value="'.$conf->entity.
'">';
886 print
'<table class="border centpercent">';
889 print
'<tr><td><label for="civility_code">'.$langs->trans(
"UserTitle").
'</label></td><td>';
890 print $formcompany->select_civility(
GETPOSTISSET(
"civility_code") ?
GETPOST(
"civility_code",
'aZ09') : $object->civility_code,
'civility_code');
895 print
'<td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans(
"Lastname").
'</span></td>';
897 if (!empty($ldap_lastname)) {
898 print
'<input type="hidden" id="lastname" name="lastname" value="'.dol_escape_htmltag($ldap_lastname).
'">';
899 print $ldap_lastname;
901 print
'<input class="minwidth100 maxwidth150onsmartphone createloginauto" type="text" id="lastname" name="lastname" value="'.dol_escape_htmltag(
GETPOST(
'lastname',
'alphanohtml')).
'">';
906 print
'<tr><td>'.$langs->trans(
"Firstname").
'</td>';
908 if (!empty($ldap_firstname)) {
909 print
'<input type="hidden" name="firstname" value="'.dol_escape_htmltag($ldap_firstname).
'">';
910 print $ldap_firstname;
912 print
'<input id="firstname" class="minwidth100 maxwidth150onsmartphone createloginauto" type="text" name="firstname" value="'.dol_escape_htmltag(
GETPOST(
'firstname',
'alphanohtml')).
'">';
917 print
'<tr><td><span class="fieldrequired">'.$langs->trans(
"Login").
'</span></td>';
919 if (!empty($ldap_login)) {
920 print
'<input type="hidden" name="login" value="'.dol_escape_htmltag($ldap_login).
'">';
922 } elseif (!empty($ldap_loginsmb)) {
923 print
'<input type="hidden" name="login" value="'.dol_escape_htmltag($ldap_loginsmb).
'">';
924 print $ldap_loginsmb;
926 print
'<input id="login" class="maxwidth200 maxwidth150onsmartphone" maxsize="24" type="text" name="login" value="'.dol_escape_htmltag(
GETPOST(
'login',
'alphanohtml')).
'">';
930 if (!empty($conf->use_javascript_ajax)) {
932 jQuery(document).ready(function() {
933 $(".createloginauto").on("change", function(){
934 lastname = $("#lastname").val();
935 firstname = $("#firstname").val();
936 if($(this).attr("id") == "firstname"){
937 firstname = firstname.toLowerCase();
938 firstname = firstname[0];
940 lastname = lastname.toLowerCase();
941 console.log("We create a login from firstname and lastname");
942 $("#login").val(firstname+lastname);
948 $generated_password =
'';
949 if (empty($ldap_sid)) {
955 if (!empty($user->admin)) {
956 print
'<tr><td>'.$langs->trans(
"Administrator").
'</td>';
958 print
$form->selectyesno(
'admin',
GETPOST(
'admin'), 1,
false, 0, 1);
961 if (!empty($conf->use_javascript_ajax)) {
962 print
'<script type="text/javascript">
964 $("select[name=admin]").change(function() {
965 if ( $(this).val() == 0 ) {
966 $("input[name=superadmin]")
967 .prop("disabled", true)
968 .prop("checked", false);
969 $("select[name=entity]")
970 .prop("disabled", false);
972 $("input[name=superadmin]")
973 .prop("disabled", false);
976 $("input[name=superadmin]").change(function() {
977 if ( $(this).is(":checked") ) {
978 $("select[name=entity]")
979 .prop("disabled", true);
981 $("select[name=entity]")
982 .prop("disabled", false);
988 $checked = (
GETPOST(
'superadmin',
'int') ?
' checked' :
'');
989 $disabled = (
GETPOST(
'superadmin',
'int') ?
'' :
' disabled');
990 print
'<input type="checkbox" name="superadmin" id="superadmin" value="1"'.$checked.$disabled.
' /> <label for="superadmin">'.$langs->trans(
"SuperAdministrator").
'</span>';
992 print
"</td></tr>\n";
996 print
'<tr><td>'.$langs->trans(
"Gender").
'</td>';
998 $arraygender = array(
'man'=>$langs->trans(
"Genderman"),
'woman'=>$langs->trans(
"Genderwoman"),
'other'=>$langs->trans(
"Genderother"));
999 print
$form->selectarray(
'gender', $arraygender,
GETPOST(
'gender'), 1);
1003 $defaultemployee =
'1';
1005 print
'<td>'.$langs->trans(
'Employee').
'</td><td>';
1006 print
'<input type="checkbox" name="employee" value="1"'.(GETPOST(
'employee') ==
'1' ?
' checked="checked"' : (($defaultemployee && !
GETPOSTISSET(
'login')) ?
' checked="checked"' :
'')).
'>';
1011 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"HierarchicalResponsible").
'</td>';
1013 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');
1019 print
'<tr><td class="titlefieldcreate">';
1020 $text = $langs->trans(
"ForceUserExpenseValidator");
1021 print
$form->textwithpicto($text, $langs->trans(
"ValidatorIsSupervisorByDefault"), 1,
'help');
1024 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');
1031 print
'<tr><td class="titlefieldcreate">';
1032 $text = $langs->trans(
"ForceUserHolidayValidator");
1033 print
$form->textwithpicto($text, $langs->trans(
"ValidatorIsSupervisorByDefault"), 1,
'help');
1036 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');
1042 print
'<tr><td>'.$langs->trans(
"ExternalUser").
' ?</td>';
1044 print
$form->textwithpicto($langs->trans(
"Internal"), $langs->trans(
"InternalExternalDesc"), 1,
'help',
'', 0, 2);
1048 print
'</table><hr><table class="border centpercent">';
1052 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"RangeOfLoginValidity").
'</td>';
1054 print
$form->selectDate($datestartvalidity,
'datestartvalidity', 0, 0, 1,
'formdatestartvalidity', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"from"));
1058 print
$form->selectDate($dateendvalidity,
'dateendvalidity', 0, 0, 1,
'formdateendvalidity', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"));
1063 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Password").
'</td>';
1066 if (preg_match(
'/ldap/', $dolibarr_main_authentication)) {
1067 $valuetoshow .= ($valuetoshow ?
' + ' :
'').$langs->trans(
"PasswordOfUserInLDAP").
' (hidden)';
1069 if (preg_match(
'/http/', $dolibarr_main_authentication)) {
1070 $valuetoshow .= ($valuetoshow ?
' + ' :
'').$langs->trans(
"HTTPBasicPassword");
1072 if (preg_match(
'/dolibarr/', $dolibarr_main_authentication) || preg_match(
'/forceuser/', $dolibarr_main_authentication)) {
1073 if (!empty($ldap_pass)) {
1074 $valuetoshow .= ($valuetoshow ?
' + ' :
'').
'<input type="hidden" name="password" value="'.
dol_escape_htmltag($ldap_pass).
'">';
1075 $valuetoshow .= preg_replace(
'/./i',
'*', $ldap_pass);
1078 $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">';
1079 if (!empty($conf->use_javascript_ajax)) {
1080 $valuetoshow .=
img_picto($langs->trans(
'Generate'),
'refresh',
'id="generate_password" class="linkobject paddingleft"');
1086 $parameters = array(
'valuetoshow' => $valuetoshow,
'password' => $password);
1087 $reshook = $hookmanager->executeHooks(
'printUserPasswordField',
$parameters, $object, $action);
1089 $valuetoshow = $hookmanager->resPrint;
1091 $valuetoshow .= $hookmanager->resPrint;
1100 print
'<tr><td>'.$langs->trans(
"ApiKey").
'</td>';
1102 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">';
1103 if (!empty($conf->use_javascript_ajax)) {
1104 print
img_picto($langs->trans(
'Generate'),
'refresh',
'id="generate_api_key" class="linkobject paddingleft"');
1110 print
'<input type="hidden" name="api_key" value="'.$generated_fake_api_key.
'">';
1114 print
'</table><hr><table class="border centpercent">';
1118 print
'<tr><td class="tdtop titlefieldcreate">'.$form->editfieldkey(
'Address',
'address',
'', $object, 0).
'</td>';
1119 print
'<td><textarea name="address" id="address" class="quatrevingtpercent" rows="3" wrap="soft">';
1120 print $object->address;
1121 print
'</textarea></td></tr>';
1124 print
'<tr><td>'.$form->editfieldkey(
'Zip',
'zipcode',
'', $object, 0).
'</td><td>';
1125 print $formcompany->select_ziptown($object->zip,
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6);
1129 print
'<tr><td>'.$form->editfieldkey(
'Town',
'town',
'', $object, 0).
'</td><td>';
1130 print $formcompany->select_ziptown($object->town,
'town', array(
'zipcode',
'selectcountry_id',
'state_id'));
1134 print
'<tr><td>'.$form->editfieldkey(
'Country',
'selectcountry_id',
'', $object, 0).
'</td><td class="maxwidthonsmartphone">';
1135 print
img_picto(
'',
'country',
'class="pictofixedwidth"');
1136 print
$form->select_country((
GETPOST(
'country_id') !=
'' ?
GETPOST(
'country_id') : $object->country_id));
1138 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1143 if (empty($conf->global->USER_DISABLE_STATE)) {
1144 print
'<tr><td>'.$form->editfieldkey(
'State',
'state_id',
'', $object, 0).
'</td><td class="maxwidthonsmartphone">';
1145 print
img_picto(
'',
'state',
'class="pictofixedwidth"');
1146 print $formcompany->select_state($object->state_id, $object->country_code,
'state_id');
1151 print
'<tr><td>'.$langs->trans(
"PhonePro").
'</td>';
1153 print
img_picto(
'',
'object_phoning',
'class="pictofixedwidth"');
1154 if (!empty($ldap_phone)) {
1155 print
'<input type="hidden" name="office_phone" value="'.dol_escape_htmltag($ldap_phone).
'">';
1158 print
'<input class="maxwidth200 widthcentpercentminusx" type="text" name="office_phone" value="'.dol_escape_htmltag(
GETPOST(
'office_phone',
'alphanohtml')).
'">';
1163 print
'<tr><td>'.$langs->trans(
"PhoneMobile").
'</td>';
1165 print
img_picto(
'',
'object_phoning_mobile',
'class="pictofixedwidth"');
1166 if (!empty($ldap_mobile)) {
1167 print
'<input type="hidden" name="user_mobile" value="'.dol_escape_htmltag($ldap_mobile).
'">';
1170 print
'<input class="maxwidth200 widthcentpercentminusx" type="text" name="user_mobile" value="'.dol_escape_htmltag(
GETPOST(
'user_mobile',
'alphanohtml')).
'">';
1175 print
'<tr><td>'.$langs->trans(
"Fax").
'</td>';
1177 print
img_picto(
'',
'object_phoning_fax',
'class="pictofixedwidth"');
1178 if (!empty($ldap_fax)) {
1179 print
'<input type="hidden" name="office_fax" value="'.dol_escape_htmltag($ldap_fax).
'">';
1182 print
'<input class="maxwidth200 widthcentpercentminusx" type="text" name="office_fax" value="'.dol_escape_htmltag(
GETPOST(
'office_fax',
'alphanohtml')).
'">';
1187 print
'<tr><td'.(!empty($conf->global->USER_MAIL_REQUIRED) ?
' class="fieldrequired"' :
'').
'>'.$langs->trans(
"EMail").
'</td>';
1189 print
img_picto(
'',
'object_email',
'class="pictofixedwidth"');
1190 if (!empty($ldap_mail)) {
1191 print
'<input type="hidden" name="email" value="'.dol_escape_htmltag($ldap_mail).
'">';
1194 print
'<input type="text" name="email" class="maxwidth500 widthcentpercentminusx" value="'.dol_escape_htmltag(
GETPOST(
'email',
'alphanohtml')).
'">';
1200 foreach ($socialnetworks as $key => $value) {
1201 if ($value[
'active']) {
1202 print
'<tr><td>'.$langs->trans($value[
'label']).
'</td>';
1204 if (!empty($value[
'icon'])) {
1205 print
'<span class="fa '.$value[
'icon'].
' pictofixedwidth"></span>';
1207 if (!empty($ldap_social[$key])) {
1208 print
'<input type="hidden" name="'.$key.
'" value="'.$ldap_social[$key].
'">';
1209 print $ldap_social[$key];
1211 print
'<input class="maxwidth200 widthcentpercentminusx" type="text" name="'.$key.
'" value="'.
GETPOST($key,
'alphanohtml').
'">';
1216 if (!empty($ldap_social[$key])) {
1217 print
'<input type="hidden" name="'.$key.
'" value="'.$ldap_social[$key].
'">';
1219 print
'<input type="hidden" name="'.$key.
'" value="'.
GETPOST($key,
'alphanohtml').
'">';
1227 print
'<tr><td>'.$langs->trans(
"AccountancyCode").
'</td>';
1229 print
'<input type="text" class="maxwidthonsmartphone" name="accountancy_code" value="'.dol_escape_htmltag(
GETPOST(
'accountancy_code',
'alphanohtml')).
'">';
1235 print
'<tr><td>'.$langs->trans(
"ColorUser").
'</td>';
1237 print $formother->selectColor(
GETPOSTISSET(
'color') ?
GETPOST(
'color',
'alphanohtml') : $object->color,
'color',
null, 1,
'',
'hideifnotset');
1242 if (
isModEnabled(
'categorie') && $user->hasRight(
"categorie",
"read")) {
1243 print
'<tr><td>'.$form->editfieldkey(
'Categories',
'usercats',
'', $object, 0).
'</td><td>';
1244 $cate_arbo =
$form->select_all_categories(
'user',
null,
'parent',
null,
null, 1);
1245 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'usercats', $cate_arbo,
GETPOST(
'usercats',
'array'), 0, 0,
'maxwdith300 widthcentpercentminusx', 0,
'90%');
1251 print
'<tr><td>'.$form->editfieldkey(
'DefaultLang',
'default_lang',
'', $object, 0,
'string',
'', 0, 0,
'id', $langs->trans(
"WarningNotLangOfInterface", $langs->transnoentitiesnoconv(
"UserGUISetup"))).
'</td>';
1252 print
'<td class="maxwidthonsmartphone">'.
"\n";
1253 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');
1261 if (!method_exists($mc,
'formObjectOptions')) {
1262 if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && !$user->entity) {
1263 print
"<tr>".
'<td>'.$langs->trans(
"Entity").
'</td>';
1264 print
"<td>".$mc->select_entities($conf->entity);
1265 print
"</td></tr>\n";
1267 print
'<input type="hidden" name="entity" value="'.$conf->entity.
'" />';
1274 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
1277 print
'<tr><td class="tdtop">'.$langs->trans(
"Signature").
'</td>';
1278 print
'<td class="wordbreak">';
1279 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1281 $doleditor =
new DolEditor(
'signature',
GETPOST(
'signature',
'restricthtml'),
'', 138,
'dolibarr_notes',
'In',
true, $acceptlocallinktomedia, empty($conf->global->FCKEDITOR_ENABLE_USERSIGN) ? 0 : 1, ROWS_4,
'90%');
1282 print $doleditor->Create(1);
1286 print
'<tr><td class="tdtop">';
1287 print $langs->trans(
"NotePublic");
1289 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1290 $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%');
1291 $doleditor->Create();
1292 print
"</td></tr>\n";
1295 print
'<tr><td class="tdtop">';
1296 print $langs->trans(
"NotePrivate");
1298 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1299 $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%');
1300 $doleditor->Create();
1301 print
"</td></tr>\n";
1303 print
'</table><hr><table class="border centpercent">';
1309 if (
isModEnabled(
'stock') && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE_USER)) {
1310 print
'<tr><td>'.$langs->trans(
"DefaultWarehouse").
'</td><td>';
1311 print $formproduct->selectWarehouses($object->fk_warehouse,
'fk_warehouse',
'warehouseopen', 1);
1316 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"PostOrFunction").
'</td>';
1318 print
'<input class="maxwidth200 maxwidth150onsmartphone" type="text" name="job" value="'.dol_escape_htmltag(
GETPOST(
'job',
'alphanohtml')).
'">';
1321 if ((
isModEnabled(
'salaries') && $user->hasRight(
"salaries",
"read") && in_array($id, $childids))
1322 || (
isModEnabled(
'salaries') && $user->hasRight(
"salaries",
"readall"))
1323 || (
isModEnabled(
'hrm') && $user->hasRight(
"hrm",
"employee",
"read"))) {
1324 $langs->load(
"salaries");
1328 $text = $langs->trans(
"THM");
1329 print
$form->textwithpicto($text, $langs->trans(
"THMDescription"), 1,
'help',
'classthm');
1332 print
'<input size="8" type="text" name="thm" value="'.dol_escape_htmltag(
GETPOST(
'thm')).
'"> '.$langs->getCurrencySymbol($conf->currency);
1338 $text = $langs->trans(
"TJM");
1339 print
$form->textwithpicto($text, $langs->trans(
"TJMDescription"), 1,
'help',
'classtjm');
1342 print
'<input size="8" type="text" name="tjm" value="'.dol_escape_htmltag(
GETPOST(
'tjm')).
'"> '.$langs->getCurrencySymbol($conf->currency);
1347 print
'<tr><td>'.$langs->trans(
"Salary").
'</td>';
1349 print
img_picto(
'',
'salary',
'class="pictofixedwidth paddingright"').
'<input class="width100" type="text" name="salary" value="'.
dol_escape_htmltag(
GETPOST(
'salary')).
'"> '.$langs->getCurrencySymbol($conf->currency);
1355 print
'<tr><td>'.$langs->trans(
"WeeklyHours").
'</td>';
1357 print
'<input size="8" type="text" name="weeklyhours" value="'.dol_escape_htmltag(
GETPOST(
'weeklyhours')).
'">';
1362 print
'<tr><td>'.$langs->trans(
"DateOfEmployment").
'</td>';
1364 print
$form->selectDate($dateemployment,
'dateemployment', 0, 0, 1,
'formdateemployment', 1, 1, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"from"));
1368 print
$form->selectDate($dateemploymentend,
'dateemploymentend', 0, 0, 1,
'formdateemploymentend', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"));
1373 print
'<tr><td>'.$langs->trans(
"DateOfBirth").
'</td>';
1375 print
$form->selectDate($dateofbirth,
'dateofbirth', 0, 0, 1,
'createuser', 1, 0, 0,
'', 0,
'',
'', 1,
'',
'',
'tzserver');
1383 print
$form->buttonsSaveCancel(
"CreateUser");
1389 $res = $object->fetch($id,
'',
'', 1);
1394 $res = $object->fetch_optionals();
1397 if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
1398 $object->getrights();
1399 if (empty($object->nb_rights) && $object->statut != 0 && empty($object->admin)) {
1406 if (
isModEnabled(
'ldap') && !empty($object->ldap_sid)) {
1408 $result = $ldap->connect_bind();
1410 $userSearchFilter =
'('.$conf->global->LDAP_FILTER_CONNECTION.
'('.$ldap->getUserIdentifier().
'='.$object->login.
'))';
1411 $entries = $ldap->fetch($object->login, $userSearchFilter);
1416 $passDoNotExpire = 0;
1417 $userChangePassNextLogon = 0;
1422 if (count($ldap->uacf) > 0) {
1423 foreach ($ldap->uacf as $key => $statut) {
1424 if ($key == 65536) {
1425 $passDoNotExpire = 1;
1426 $statutUACF = $statut;
1431 $statutUACF =
"ACCOUNTDISABLE";
1434 if ($ldap->pwdlastset == 0) {
1435 $userChangePassNextLogon = 1;
1441 if ($mode ==
'employee') {
1442 $title = $langs->trans(
"Employee");
1443 $linkback =
'<a href="'.DOL_URL_ROOT.
'/hrm/employee/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
1445 $title = $langs->trans(
"User");
1448 if ($user->hasRight(
"user",
"user",
"read") || $user->admin) {
1449 $linkback =
'<a href="'.DOL_URL_ROOT.
'/user/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
1458 if ($action ==
'password') {
1459 print
$form->formconfirm($_SERVER[
'PHP_SELF'].
"?id=$object->id", $langs->trans(
"ReinitPassword"), $langs->trans(
"ConfirmReinitPassword", $object->login),
"confirm_password",
'', 0, 1);
1465 if ($action ==
'passwordsend') {
1466 print
$form->formconfirm($_SERVER[
'PHP_SELF'].
"?id=$object->id", $langs->trans(
"SendNewPassword"), $langs->trans(
"ConfirmSendNewPassword", $object->login),
"confirm_passwordsend",
'', 0, 1);
1472 if ($action ==
'disable') {
1473 print
$form->formconfirm($_SERVER[
'PHP_SELF'].
"?id=$object->id", $langs->trans(
"DisableAUser"), $langs->trans(
"ConfirmDisableUser", $object->login),
"confirm_disable",
'', 0, 1);
1479 if ($action ==
'enable') {
1480 print
$form->formconfirm($_SERVER[
'PHP_SELF'].
"?id=$object->id", $langs->trans(
"EnableAUser"), $langs->trans(
"ConfirmEnableUser", $object->login),
"confirm_enable",
'', 0, 1);
1486 if ($action ==
'delete') {
1487 print
$form->formconfirm($_SERVER[
'PHP_SELF'].
"?id=$object->id", $langs->trans(
"DeleteAUser"), $langs->trans(
"ConfirmDeleteUser", $object->login),
"confirm_delete",
'', 0, 1);
1493 if ($action !=
'edit') {
1496 $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">';
1497 $morehtmlref .=
img_picto($langs->trans(
"Download").
' '.$langs->trans(
"VCard").
' ('.$langs->trans(
"AddToContacts").
')',
'vcard.png',
'class="valignmiddle marginleftonly paddingrightonly"');
1498 $morehtmlref .=
'</a>';
1500 $urltovirtualcard =
'/user/virtualcard.php?id='.((int) $object->id);
1501 $morehtmlref .=
dolButtonToOpenUrlInDialogPopup(
'publicvirtualcard', $langs->trans(
"PublicVirtualCardUrl").
' - '.$object->getFullName($langs),
img_picto($langs->trans(
"PublicVirtualCardUrl"),
'card',
'class="valignmiddle marginleftonly paddingrightonly"'), $urltovirtualcard,
'',
'nohover');
1503 dol_banner_tab($object,
'id', $linkback, $user->hasRight(
"user",
"user",
"read") || $user->admin,
'rowid',
'ref', $morehtmlref);
1505 print
'<div class="fichecenter">';
1506 print
'<div class="fichehalfleft">';
1508 print
'<div class="underbanner clearboth"></div>';
1509 print
'<table class="border tableforfield centpercent">';
1512 print
'<tr><td class="titlefieldmiddle">'.$langs->trans(
"Login").
'</td>';
1513 if (!empty($object->ldap_sid) && $object->statut == 0) {
1514 print
'<td class="error">';
1515 print $langs->trans(
"LoginAccountDisableInDolibarr");
1520 if (property_exists($object,
'admin')) {
1521 if (
isModEnabled(
'multicompany') && !empty($object->admin) && empty($object->entity)) {
1522 $addadmin .=
img_picto($langs->trans(
"SuperAdministratorDesc"),
"redstar",
'class="paddingleft"');
1523 } elseif (!empty($object->admin)) {
1524 $addadmin .=
img_picto($langs->trans(
"AdministratorDesc"),
"star",
'class="paddingleft"');
1534 $text = $langs->trans(
"Type");
1535 print
$form->textwithpicto($text, $langs->trans(
"InternalExternalDesc"));
1537 $type = $langs->trans(
"Internal");
1538 if ($object->socid > 0) {
1539 $type = $langs->trans(
"External");
1541 print
'<span class="badgeneutral">';
1543 if ($object->ldap_sid) {
1544 print
' ('.$langs->trans(
"DomainUser").
')';
1547 print
'</td></tr>'.
"\n";
1550 if ($object->ldap_sid) {
1551 print
'<tr><td>'.$langs->trans(
"Type").
'</td><td>';
1552 print $langs->trans(
"DomainUser", $ldap->domainFQDN);
1553 print
'</td></tr>'.
"\n";
1557 print
'<tr><td>'.$langs->trans(
"Employee").
'</td><td>';
1558 print
'<input type="checkbox" disabled name="employee" value="1"'.($object->employee ?
' checked="checked"' :
'').
'>';
1560 print
'</td></tr>'.
"\n";
1565 print
'<tr><td>'.$langs->trans(
"HierarchicalResponsible").
'</td>';
1567 if (empty($object->fk_user)) {
1568 print
'<span class="opacitymedium">'.$langs->trans(
"None").
'</span>';
1570 $huser =
new User($db);
1571 if ($object->fk_user > 0) {
1572 $huser->fetch($object->fk_user);
1573 print $huser->getNomUrl(-1);
1575 print
'<span class="opacitymedium">'.$langs->trans(
"None").
'</span>';
1584 $text = $langs->trans(
"ForceUserExpenseValidator");
1585 print
$form->textwithpicto($text, $langs->trans(
"ValidatorIsSupervisorByDefault"), 1,
'help');
1588 if (!empty($object->fk_user_expense_validator)) {
1589 $evuser =
new User($db);
1590 $evuser->fetch($object->fk_user_expense_validator);
1591 print $evuser->getNomUrl(-1);
1600 $text = $langs->trans(
"ForceUserHolidayValidator");
1601 print
$form->textwithpicto($text, $langs->trans(
"ValidatorIsSupervisorByDefault"), 1,
'help');
1604 if (!empty($object->fk_user_holiday_validator)) {
1605 $hvuser =
new User($db);
1606 $hvuser->fetch($object->fk_user_holiday_validator);
1607 print $hvuser->getNomUrl(-1);
1614 print
'<tr><td>'.$langs->trans(
"PostOrFunction").
'</td>';
1615 print
'<td>'.dol_escape_htmltag($object->job).
'</td>';
1619 print
'<tr><td>'.$langs->trans(
"WeeklyHours").
'</td>';
1626 if ((empty($user->socid) && in_array($id, $childids))
1627 || (
isModEnabled(
'salaries') && $user->hasRight(
"salaries",
"readall"))
1628 || (
isModEnabled(
'hrm') && $user->hasRight(
"hrm",
"employee",
"read"))) {
1629 $langs->load(
"salaries");
1632 print
'<tr><td>'.$langs->trans(
"Salary").
'</td>';
1634 print ($object->salary !=
'' ?
img_picto(
'',
'salary',
'class="pictofixedwidth paddingright"').
'<span class="amount">'.
price($object->salary,
'', $langs, 1, -1, -1, $conf->currency) :
'').
'</span>';
1640 $text = $langs->trans(
"THM");
1641 print
$form->textwithpicto($text, $langs->trans(
"THMDescription"), 1,
'help',
'classthm');
1644 print ($object->thm !=
'' ?
price($object->thm,
'', $langs, 1, -1, -1, $conf->currency) :
'');
1650 $text = $langs->trans(
"TJM");
1651 print
$form->textwithpicto($text, $langs->trans(
"TJMDescription"), 1,
'help',
'classtjm');
1654 print ($object->tjm !=
'' ?
price($object->tjm,
'', $langs, 1, -1, -1, $conf->currency) :
'');
1660 print
'<tr><td>'.$langs->trans(
"DateOfEmployment").
'</td>';
1662 if ($object->dateemployment) {
1663 print
'<span class="opacitymedium">'.$langs->trans(
"FromDate").
'</span> ';
1666 if ($object->dateemploymentend) {
1667 print
'<span class="opacitymedium"> - '.$langs->trans(
"To").
'</span> ';
1674 print
'<tr><td>'.$langs->trans(
"DateOfBirth").
'</td>';
1681 if (
isModEnabled(
'stock') && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE_USER)) {
1682 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/entrepot.class.php';
1683 print
'<tr><td>'.$langs->trans(
"DefaultWarehouse").
'</td><td>';
1684 if ($object->fk_warehouse > 0) {
1685 $warehousestatic =
new Entrepot($db);
1686 $warehousestatic->fetch($object->fk_warehouse);
1687 print $warehousestatic->getNomUrl(1);
1695 print
'<div class="fichehalfright">';
1697 print
'<div class="underbanner clearboth"></div>';
1699 print
'<table class="border tableforfield centpercent">';
1703 print
'<tr><td class="titlefield">'.$langs->trans(
"ColorUser").
'</td>';
1705 print $formother->showColor($object->color,
'');
1711 if (
isModEnabled(
'categorie') && $user->hasRight(
"categorie",
"read")) {
1712 print
'<tr><td class="titlefield">'.$langs->trans(
"Categories").
'</td>';
1713 print
'<td colspan="3">';
1714 print
$form->showCategories($object->id, Categorie::TYPE_USER, 1);
1720 $langs->load(
"languages");
1721 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
1722 print
'<tr><td class="titlefield">';
1723 print
$form->textwithpicto($langs->trans(
"DefaultLang"), $langs->trans(
"WarningNotLangOfInterface", $langs->transnoentitiesnoconv(
"UserGUISetup")));
1727 $labellang = ($object->lang ? $langs->trans(
'Language_'.$object->lang) :
'');
1728 print
picto_from_langcode($object->lang,
'class="paddingrightonly saturatemedium opacitylow"');
1733 if (isset($conf->file->main_authentication) && preg_match(
'/openid/', $conf->file->main_authentication) && !empty($conf->global->MAIN_OPENIDURL_PERUSER)) {
1734 print
'<tr><td>'.$langs->trans(
"OpenIDURL").
'</td>';
1735 print
'<td>'.$object->openid.
'</td>';
1742 if (!method_exists($mc,
'formObjectOptions')) {
1743 if (
isModEnabled(
'multicompany') && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && !$user->entity) {
1744 print
'<tr><td>'.$langs->trans(
"Entity").
'</td><td>';
1745 if (empty($object->entity)) {
1746 print $langs->trans(
"AllEntities");
1748 $mc->getInfo($object->entity);
1751 print
"</td></tr>\n";
1757 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
1761 print
'<tr><td>'.$langs->trans(
"LinkToCompanyContact").
'</td>';
1764 if (isset($object->socid) && $object->socid > 0) {
1766 $societe->fetch($object->socid);
1767 if ($societe->id > 0) {
1768 $s .= $societe->getNomUrl(1,
'');
1771 $s .=
'<span class="opacitymedium hideonsmartphone">'.$langs->trans(
"ThisUserIsNot").
'</span>';
1773 if (!empty($object->contact_id)) {
1775 $contact->fetch($object->contact_id);
1776 if ($contact->id > 0) {
1777 if ($object->socid > 0 && $s) {
1782 $s .= $contact->getNomUrl(1,
'');
1792 $langs->load(
"members");
1793 print
'<tr><td>'.$langs->trans(
"LinkedToDolibarrMember").
'</td>';
1795 if ($object->fk_member) {
1797 $adh->fetch($object->fk_member);
1798 $adh->ref = $adh->getFullname($langs);
1799 print $adh->getNomUrl(-1);
1801 print
'<span class="opacitymedium hideonsmartphone">'.$langs->trans(
"UserNotLinkedToMember").
'</span>';
1808 print
'<tr><td class="tdtop">'.$langs->trans(
'Signature').
'</td><td class="wordbreak">';
1810 print
"</td></tr>\n";
1817 print
'<div class="div-table-responsive-no-min">';
1818 print
'<table class="border tableforfield centpercent">';
1819 print
'<tr class="liste_titre"><td class="liste_titre">';
1820 print
img_picto(
'',
'security',
'class="paddingleft pictofixedwidth"').$langs->trans(
"Credentials");
1822 print
'<td class="liste_titre"></td>';
1826 print
'<tr class="nooddeven"><td class="titlefield">'.$langs->trans(
"RangeOfLoginValidity").
'</td>';
1828 if ($object->datestartvalidity) {
1829 print
'<span class="opacitymedium">'.$langs->trans(
"FromDate").
'</span> ';
1832 if ($object->dateendvalidity) {
1833 print
'<span class="opacitymedium"> - '.$langs->trans(
"To").
'</span> ';
1841 if (preg_match(
'/ldap/', $dolibarr_main_authentication)) {
1842 if (!empty($object->ldap_sid)) {
1843 if ($passDoNotExpire) {
1844 $valuetoshow .= ($valuetoshow ? (
' '.$langs->trans(
"or").
' ') :
'').$langs->trans(
"LdapUacf_".$statutUACF);
1845 } elseif ($userChangePassNextLogon) {
1846 $valuetoshow .= ($valuetoshow ? (
' '.$langs->trans(
"or").
' ') :
'').
'<span class="warning">'.$langs->trans(
"UserMustChangePassNextLogon", $ldap->domainFQDN).
'</span>';
1847 } elseif ($userDisabled) {
1848 $valuetoshow .= ($valuetoshow ? (
' '.$langs->trans(
"or").
' ') :
'').
'<span class="warning">'.$langs->trans(
"LdapUacf_".$statutUACF, $ldap->domainFQDN).
'</span>';
1850 $valuetoshow .= ($valuetoshow ? (
' '.$langs->trans(
"or").
' ') :
'').$langs->trans(
"PasswordOfUserInLDAP");
1853 $valuetoshow .= ($valuetoshow ? (
' '.$langs->trans(
"or").
' ') :
'').$langs->trans(
"PasswordOfUserInLDAP");
1856 if (preg_match(
'/http/', $dolibarr_main_authentication)) {
1857 $valuetoshow .= ($valuetoshow ? (
' '.$langs->trans(
"or").
' ') :
'').$langs->trans(
"HTTPBasicPassword");
1878 $parameters = array(
'valuetoshow' => $valuetoshow);
1879 $reshook = $hookmanager->executeHooks(
'printUserPasswordField',
$parameters, $object, $action);
1881 $valuetoshow = $hookmanager->resPrint;
1883 $valuetoshow .= $hookmanager->resPrint;
1887 print
'<tr class="nooddeven"><td class="titlefield">'.$langs->trans(
"Password").
'</td>';
1888 print
'<td class="wordbreak">';
1895 if (
isModEnabled(
'api') && ($user->id == $id || $user->admin || $user->hasRight(
"api",
"apikey",
"generate"))) {
1896 print
'<tr class="nooddeven"><td>'.$langs->trans(
"ApiKey").
'</td>';
1898 if (!empty($object->api_key)) {
1899 print
'<span class="opacitymedium">';
1906 print
'<tr class="nooddeven"><td>'.$langs->trans(
"LastConnexion").
'</td>';
1908 if ($object->datepreviouslogin) {
1909 print
dol_print_date($object->datepreviouslogin,
"dayhour",
"tzuserrel").
' <span class="opacitymedium">('.$langs->trans(
"Previous").
')</span>, ';
1911 if ($object->datelastlogin) {
1912 print
dol_print_date($object->datelastlogin,
"dayhour",
"tzuserrel").
' <span class="opacitymedium">('.$langs->trans(
"Currently").
')</span>';
1923 print
'<div class="clearboth"></div>';
1932 print
'<div class="tabsAction">';
1935 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons',
$parameters, $object, $action);
1936 if (empty($reshook)) {
1937 if (empty($user->socid)) {
1938 $canSendMail =
false;
1942 'class' =>
'classfortooltip'
1945 if (!empty($object->email)) {
1946 $langs->load(
"mails");
1947 $canSendMail =
true;
1949 $langs->load(
"mails");
1950 $params[
'attr'][
'title'] = $langs->trans(
'NoEMail');
1952 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'default', $_SERVER[
'PHP_SELF'] .
'?id=' . $object->id .
'&action=presend&mode=init#formmailbeforetitle',
'', $canSendMail, $params);
1955 if ($caneditfield && (!
isModEnabled(
'multicompany') || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $object->entity == 1))) {
1959 'class' =>
'classfortooltip'
1962 if (!empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED)) {
1963 $params[
'attr'][
'title'] = $langs->trans(
'DisabledInMonoUserMode');
1964 print
dolGetButtonAction($langs->trans(
'Modify'),
'',
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false, $params);
1966 print
dolGetButtonAction($langs->trans(
'Modify'),
'',
'default', $_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=edit&token='.
newToken(),
'',
true, $params);
1968 } elseif ($caneditpassword && !$object->ldap_sid &&
1969 (!
isModEnabled(
'multicompany') || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $object->entity == 1))) {
1973 'class' =>
'classfortooltip'
1976 print
dolGetButtonAction($langs->trans(
'Modify'),
'',
'default', $_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=edit',
'',
true, $params);
1983 'class' =>
'classfortooltip'
1986 if ($conf->global->USER_PASSWORD_GENERATED !=
'none') {
1987 if ($object->statut == 0) {
1988 $params[
'attr'][
'title'] = $langs->trans(
'UserDisabled');
1989 print
dolGetButtonAction($langs->trans(
'ReinitPassword'),
'',
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false, $params);
1990 } elseif (($user->id != $id && $caneditpassword) && $object->login && !$object->ldap_sid &&
1991 ((!
isModEnabled(
'multicompany') && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $object->entity == 1))) {
1992 print
dolGetButtonAction($langs->trans(
'ReinitPassword'),
'',
'default', $_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=password&token='.
newToken(),
'',
true, $params);
1995 if ($object->statut == 0) {
1996 $params[
'attr'][
'title'] = $langs->trans(
'UserDisabled');
1997 print
dolGetButtonAction($langs->trans(
'SendNewPassword'),
'',
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false, $params);
1998 } elseif (($user->id != $id && $caneditpassword) && $object->login && !$object->ldap_sid &&
1999 ((!
isModEnabled(
'multicompany') && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $object->entity == 1))) {
2000 if ($object->email) {
2001 print
dolGetButtonAction($langs->trans(
'SendNewPassword'),
'',
'default', $_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=passwordsend&token='.
newToken(),
'',
true, $params);
2003 $params[
'attr'][
'title'] = $langs->trans(
'NoEMail');
2004 print
dolGetButtonAction($langs->trans(
'SendNewPassword'),
'',
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false, $params);
2013 'class' =>
'classfortooltip'
2016 if ($user->id <> $id && $candisableuser && $object->statut == 0 &&
2017 ((!
isModEnabled(
'multicompany') && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $object->entity == 1))) {
2018 print
dolGetButtonAction($langs->trans(
'Reactivate'),
'',
'default', $_SERVER[
'PHP_SELF'] .
'?id=' . $object->id .
'&action=enable&token='.newToken(),
'',
true, $params);
2021 if ($user->id <> $id && $candisableuser && $object->statut == 1 &&
2022 ((!
isModEnabled(
'multicompany') && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $object->entity == 1))) {
2023 print
dolGetButtonAction($langs->trans(
'DisableUser'),
'',
'default', $_SERVER[
'PHP_SELF'] .
'?id=' . $object->id .
'&action=disable&token='.newToken(),
'',
true, $params);
2025 if ($user->id == $id) {
2026 $params[
'attr'][
'title'] = $langs->trans(
'CantDisableYourself');
2027 print
dolGetButtonAction($langs->trans(
'DisableUser'),
'',
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false, $params);
2031 if ($user->id <> $id && $candisableuser &&
2032 ((!
isModEnabled(
'multicompany') && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $object->entity == 1))) {
2033 if ($user->admin || !$object->admin) {
2034 print
dolGetButtonAction($langs->trans(
'DeleteUser'),
'',
'default', $_SERVER[
'PHP_SELF'].
'?action=delete&token='.
newToken().
'&id='.$object->id,
'',
true, $params);
2036 $params[
'attr'][
'title'] = $langs->trans(
'MustBeAdminToDeleteOtherAdmin');
2037 print
dolGetButtonAction($langs->trans(
'DeleteUser'),
'',
'default', $_SERVER[
'PHP_SELF'].
'?action=delete&token='.
newToken().
'&id='.$object->id,
'',
false, $params);
2047 if (
GETPOST(
'modelselected')) {
2048 $action =
'presend';
2052 $modelmail =
'user';
2053 $defaulttopic =
'Information';
2054 $diroutput = $conf->user->dir_output;
2055 $trackid =
'use'.$object->id;
2057 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
2059 if ($action !=
'presend' && $action !=
'send') {
2064 if ($canreadgroup) {
2065 print
'<!-- Group section -->'.
"\n";
2073 $groupslist = $usergroup->listGroupsForUser($object->id,
false);
2075 if (!empty($groupslist)) {
2076 foreach ($groupslist as $groupforuser) {
2077 $exclude[] = $groupforuser->id;
2082 $parameters = array(
'caneditgroup' => $caneditgroup,
'groupslist' => $groupslist,
'exclude' => $exclude);
2083 $reshook = $hookmanager->executeHooks(
'formAddUserToGroup',
$parameters, $object, $action);
2084 print $hookmanager->resPrint;
2086 if (empty($reshook)) {
2087 if ($caneditgroup) {
2088 print
'<form action="'.$_SERVER[
'PHP_SELF'].
'?id='.$id.
'" method="POST">'.
"\n";
2089 print
'<input type="hidden" name="token" value="'.newToken().
'" />';
2090 print
'<input type="hidden" name="action" value="addgroup" />';
2091 print
'<input type="hidden" name="page_y" value="" />';
2094 print
'<!-- List of groups of the user -->'.
"\n";
2095 print
'<table class="noborder centpercent">'.
"\n";
2096 print
'<tr class="liste_titre"><th class="liste_titre">'.$langs->trans(
"Groups").
'</th>'.
"\n";
2097 print
'<th class="liste_titre right">';
2098 if ($caneditgroup) {
2099 print
$form->select_dolgroups(
'',
'group', 1, $exclude, 0,
'',
'', $object->entity,
false,
'maxwidth150');
2101 print
'<input type="hidden" name="entity" value="'.$conf->entity.
'" />';
2102 print
'<input type="submit" class="button buttongen button-add reposition" value="'.$langs->trans(
"Add").
'" />';
2104 print
'</th></tr>'.
"\n";
2107 if (!empty($groupslist)) {
2108 foreach ($groupslist as $group) {
2109 print
'<tr class="oddeven">';
2110 print
'<td class="tdoverflowmax150">';
2111 if ($caneditgroup) {
2112 print $group->getNomUrl(1);
2114 print
img_object($langs->trans(
"ShowGroup"),
"group").
' '.$group->name;
2117 print
'<td class="right">';
2118 if ($caneditgroup) {
2119 print
'<a class="reposition" href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=removegroup&token='.
newToken().
'&group='.((int) $group->id).
'">';
2120 print
img_picto($langs->trans(
"RemoveFromGroup"),
'unlink');
2125 print
"</td></tr>\n";
2128 print
'<tr class="oddeven"><td colspan="3"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
2133 if ($caneditgroup) {
2145 if ($action ==
'edit' && ($canedituser || $caneditpassword)) {
2146 print
'<form action="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'" method="POST" name="updateuser" enctype="multipart/form-data">';
2147 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2148 print
'<input type="hidden" name="action" value="update">';
2149 print
'<input type="hidden" name="entity" value="'.$object->entity.
'">';
2153 print
'<table class="border centpercent">';
2156 if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) {
2157 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Ref").
'</td>';
2165 print
'<tr><td class="titlefieldcreate"><label for="civility_code">'.$langs->trans(
"UserTitle").
'</label></td><td>';
2166 if ($caneditfield && !$object->ldap_sid) {
2167 print $formcompany->select_civility(
GETPOSTISSET(
"civility_code") ?
GETPOST(
"civility_code",
'aZ09') : $object->civility_code,
'civility_code');
2168 } elseif ($object->civility_code) {
2169 print $langs->trans(
"Civility".$object->civility_code);
2175 print
'<td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Lastname").
'</td>';
2177 if ($caneditfield && !$object->ldap_sid) {
2178 print
'<input class="minwidth100" type="text" class="flat" name="lastname" value="'.$object->lastname.
'">';
2180 print
'<input type="hidden" name="lastname" value="'.$object->lastname.
'">';
2181 print $object->lastname;
2187 print
'<tr><td>'.$langs->trans(
"Firstname").
'</td>';
2189 if ($caneditfield && !$object->ldap_sid) {
2190 print
'<input class="minwidth100" type="text" class="flat" name="firstname" value="'.$object->firstname.
'">';
2192 print
'<input type="hidden" name="firstname" value="'.$object->firstname.
'">';
2193 print $object->firstname;
2198 print
"<tr>".
'<td><span class="fieldrequired">'.$langs->trans(
"Login").
'</span></td>';
2200 if ($user->admin && !$object->ldap_sid) {
2201 print
'<input maxlength="50" type="text" class="flat" name="login" value="'.$object->login.
'">';
2203 print
'<input type="hidden" name="login" value="'.$object->login.
'">';
2204 print $object->login;
2210 print
'<tr><td>'.$langs->trans(
"Administrator").
'</td>';
2211 if ($object->socid > 0) {
2212 $langs->load(
"admin");
2214 print
'<input type="hidden" name="admin" value="'.$object->admin.
'">'.
yn($object->admin);
2215 print
' <span class="opacitymedium">('.$langs->trans(
"ExternalUser").
')</span>';
2219 $nbAdmin = $user->getNbOfUsers(
'active',
'', 1);
2220 $nbSuperAdmin = $user->getNbOfUsers(
'active',
'superadmin', 1);
2224 && ($user->id != $object->id)
2227 || (
isModEnabled(
'multicompany') && (($object->entity > 0 || ($user->entity == 0 && $object->entity == 0)) || $nbSuperAdmin > 1))
2230 print
$form->selectyesno(
'admin', $object->admin, 1,
false, 0, 1);
2233 if ($conf->use_javascript_ajax) {
2234 print
'<script type="text/javascript">
2236 var admin = $("select[name=admin]").val();
2238 $("input[name=superadmin]")
2239 .prop("disabled", true)
2240 .prop("checked", false);
2242 if ($("input[name=superadmin]").is(":checked")) {
2243 $("select[name=entity]")
2244 .prop("disabled", true);
2246 $("select[name=admin]").change(function() {
2247 if ( $(this).val() == 0 ) {
2248 $("input[name=superadmin]")
2249 .prop("disabled", true)
2250 .prop("checked", false);
2251 $("select[name=entity]")
2252 .prop("disabled", false);
2254 $("input[name=superadmin]")
2255 .prop("disabled", false);
2258 $("input[name=superadmin]").change(function() {
2259 if ( $(this).is(":checked")) {
2260 $("select[name=entity]")
2261 .prop("disabled", true);
2263 $("select[name=entity]")
2264 .prop("disabled", false);
2271 $checked = (($object->admin && !$object->entity) ?
' checked' :
'');
2272 print
'<input type="checkbox" name="superadmin" id="superadmin" value="1"'.$checked.
' /> <label for="superadmin">'.$langs->trans(
"SuperAdministrator").
'</span>';
2275 $yn =
yn($object->admin);
2276 print
'<input type="hidden" name="admin" value="'.$object->admin.
'">';
2277 print
'<input type="hidden" name="superadmin" value="'.(empty($object->entity) ? 1 : 0).
'">';
2278 if (
isModEnabled(
'multicompany') && empty($object->entity)) {
2279 print
$form->textwithpicto($yn, $langs->trans(
"DontDowngradeSuperAdmin"), 1,
'warning');
2288 print
'<tr><td>'.$langs->trans(
"Gender").
'</td>';
2290 $arraygender = array(
'man'=>$langs->trans(
"Genderman"),
'woman'=>$langs->trans(
"Genderwoman"),
'other'=>$langs->trans(
"Genderother"));
2291 if ($caneditfield) {
2294 print $arraygender[$object->gender];
2300 print
'<td>'.$form->editfieldkey(
'Employee',
'employee',
'', $object, 0).
'</td><td>';
2301 if ($caneditfield) {
2302 print
'<input type="checkbox" name="employee" value="1"'.($object->employee ?
' checked="checked"' :
'').
'>';
2305 print
'<input type="checkbox" name="employee" disabled value="1"'.($object->employee ?
' checked="checked"' :
'').
'>';
2315 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"HierarchicalResponsible").
'</td>';
2317 if ($caneditfield) {
2318 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');
2320 print
'<input type="hidden" name="fk_user" value="'.$object->fk_user.
'">';
2321 $huser =
new User($db);
2322 $huser->fetch($object->fk_user);
2323 print $huser->getNomUrl(-1);
2330 print
'<tr><td class="titlefieldcreate">';
2331 $text = $langs->trans(
"ForceUserExpenseValidator");
2332 print
$form->textwithpicto($text, $langs->trans(
"ValidatorIsSupervisorByDefault"), 1,
'help');
2335 if ($caneditfield) {
2336 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');
2338 print
'<input type="hidden" name="fk_user_expense_validator" value="'.$object->fk_user_expense_validator.
'">';
2339 $evuser =
new User($db);
2340 $evuser->fetch($object->fk_user_expense_validator);
2341 print $evuser->getNomUrl(-1);
2349 print
'<tr><td class="titlefieldcreate">';
2350 $text = $langs->trans(
"ForceUserHolidayValidator");
2351 print
$form->textwithpicto($text, $langs->trans(
"ValidatorIsSupervisorByDefault"), 1,
'help');
2354 if ($caneditfield) {
2355 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');
2357 print
'<input type="hidden" name="fk_user_holiday_validator" value="'.$object->fk_user_holiday_validator.
'">';
2358 $hvuser =
new User($db);
2359 $hvuser->fetch($object->fk_user_holiday_validator);
2360 print $hvuser->getNomUrl(-1);
2367 print
'<tr><td>'.$langs->trans(
"ExternalUser").
' ?</td>';
2369 if ($user->id == $object->id || !$user->admin) {
2371 $type = $langs->trans(
"Internal");
2372 if ($object->socid) {
2373 $type = $langs->trans(
"External");
2375 print
$form->textwithpicto($type, $langs->trans(
"InternalExternalDesc"));
2376 if ($object->ldap_sid) {
2377 print
' ('.$langs->trans(
"DomainUser").
')';
2382 if ($object->contact_id) {
2383 $type = $object->contact_id;
2386 if ($object->socid > 0 && !($object->contact_id > 0)) {
2387 print
img_picto(
'',
'company').$form->select_company($object->socid,
'socid',
'',
' ', 0, 0,
null, 0,
'maxwidth300');
2388 print
img_picto(
'',
'contact').$form->selectcontacts(0, 0,
'contactid', 1,
'',
'', 1,
'maxwidth300',
false, 1);
2389 if ($object->ldap_sid) {
2390 print
' ('.$langs->trans(
"DomainUser").
')';
2392 } elseif ($object->socid > 0 && $object->contact_id > 0) {
2393 print
img_picto(
'',
'company').$form->select_company($object->socid,
'socid',
'',
' ', 0, 0,
null, 0,
'maxwidth300');
2394 print
img_picto(
'',
'contact').$form->selectcontacts(0, $object->contact_id,
'contactid', 1,
'',
'', 1,
'maxwidth300',
false, 1);
2395 if ($object->ldap_sid) {
2396 print
' ('.$langs->trans(
"DomainUser").
')';
2398 } elseif (!($object->socid > 0) && $object->contact_id > 0) {
2399 print
img_picto(
'',
'company').$form->select_company(0,
'socid',
'',
' ', 0, 0,
null, 0,
'maxwidth300');
2400 print
img_picto(
'',
'contact').$form->selectcontacts(0, $object->contact_id,
'contactid', 1,
'',
'', 1,
'maxwidth300',
false, 1);
2401 if ($object->ldap_sid) {
2402 print
' ('.$langs->trans(
"DomainUser").
')';
2405 print
img_picto(
'',
'company').$form->select_company(0,
'socid',
'',
' ', 0, 0,
null, 0,
'maxwidth300');
2406 print
img_picto(
'',
'contact').$form->selectcontacts(0, 0,
'contactid', 1,
'',
'', 1,
'maxwidth300',
false, 1);
2416 print
'<table class="border centpercent">';
2419 print
'<tr><td>'.$langs->trans(
"RangeOfLoginValidity").
'</td>';
2421 if ($caneditfield) {
2422 print
$form->selectDate($datestartvalidity ? $datestartvalidity : $object->datestartvalidity,
'datestartvalidity', 0, 0, 1,
'formdatestartvalidity', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"from"));
2428 if ($caneditfield) {
2429 print
$form->selectDate($dateendvalidity ? $dateendvalidity : $object->dateendvalidity,
'dateendvalidity', 0, 0, 1,
'formdateendvalidity', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"));
2437 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Password").
'</td>';
2440 if (preg_match(
'/ldap/', $dolibarr_main_authentication)) {
2441 $valuetoshow .= ($valuetoshow ? (
' '.$langs->trans(
"or").
' ') :
'').$langs->trans(
"PasswordOfUserInLDAP");
2443 if (preg_match(
'/http/', $dolibarr_main_authentication)) {
2444 $valuetoshow .= ($valuetoshow ? (
' '.$langs->trans(
"or").
' ') :
'').
$form->textwithpicto($text, $langs->trans(
"DolibarrInHttpAuthenticationSoPasswordUseless", $dolibarr_main_authentication), 1,
'warning');
2446 if (preg_match(
'/dolibarr/', $dolibarr_main_authentication) || preg_match(
'/forceuser/', $dolibarr_main_authentication)) {
2447 if ($caneditpassword) {
2448 $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">';
2449 if (!empty($conf->use_javascript_ajax)) {
2450 $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').
'"');
2453 $valuetoshow .= ($valuetoshow ? (
' '.$langs->trans(
"or").
' ') :
'').preg_replace(
'/./i',
'*', $object->pass);
2457 $parameters = array(
'valuetoshow' => $valuetoshow,
'caneditpassword' => $caneditpassword);
2458 $reshook = $hookmanager->executeHooks(
'printUserPasswordField',
$parameters, $object, $action);
2460 $valuetoshow = $hookmanager->resPrint;
2462 $valuetoshow .= $hookmanager->resPrint;
2466 print
"</td></tr>\n";
2470 print
'<tr><td>'.$langs->trans(
"ApiKey").
'</td>';
2472 if ($caneditpassword || $user->hasRight(
"api",
"apikey",
"generate")) {
2473 print
'<input class="minwidth300 maxwidth400 widthcentpercentminusx" minlength="12" maxlength="128" type="text" id="api_key" name="api_key" value="'.$object->api_key.
'" autocomplete="off">';
2474 if (!empty($conf->use_javascript_ajax)) {
2475 print
img_picto($langs->trans(
'Generate'),
'refresh',
'id="generate_api_key" class="linkobject paddingleft"');
2482 if (isset($conf->file->main_authentication) && preg_match(
'/openid/', $conf->file->main_authentication) && !empty($conf->global->MAIN_OPENIDURL_PERUSER)) {
2483 print
"<tr>".
'<td>'.$langs->trans(
"OpenIDURL").
'</td>';
2485 if ($caneditfield) {
2486 print
'<input class="minwidth100" type="url" name="openid" class="flat" value="'.$object->openid.
'">';
2488 print
'<input type="hidden" name="openid" value="'.$object->openid.
'">';
2489 print $object->openid;
2494 print
'</table><hr><table class="border centpercent">';
2498 print
'<tr><td class="tdtop titlefieldcreate">'.$form->editfieldkey(
'Address',
'address',
'', $object, 0).
'</td>';
2500 if ($caneditfield) {
2501 print
'<textarea name="address" id="address" class="quatrevingtpercent" rows="3" wrap="soft">';
2503 print $object->address;
2504 if ($caneditfield) {
2505 print
'</textarea>';
2510 print
'<tr><td>'.$form->editfieldkey(
'Zip',
'zipcode',
'', $object, 0).
'</td><td>';
2511 if ($caneditfield) {
2512 print $formcompany->select_ziptown($object->zip,
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6);
2519 print
'<tr><td>'.$form->editfieldkey(
'Town',
'town',
'', $object, 0).
'</td><td>';
2520 if ($caneditfield) {
2521 print $formcompany->select_ziptown($object->town,
'town', array(
'zipcode',
'selectcountry_id',
'state_id'));
2523 print $object->town;
2528 print
'<tr><td>'.$form->editfieldkey(
'Country',
'selectcounty_id',
'', $object, 0).
'</td><td>';
2529 print
img_picto(
'',
'country',
'class="pictofixedwidth"');
2530 if ($caneditfield) {
2531 print
$form->select_country((
GETPOST(
'country_id') !=
'' ?
GETPOST(
'country_id') : $object->country_id),
'country_id');
2533 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
2536 $countrylabel =
getCountry($object->country_id,
'0');
2537 print $countrylabel;
2542 if (empty($conf->global->USER_DISABLE_STATE)) {
2543 print
'<tr><td class="tdoverflow">'.$form->editfieldkey(
'State',
'state_id',
'', $object, 0).
'</td><td>';
2544 if ($caneditfield) {
2545 print
img_picto(
'',
'state',
'class="pictofixedwidth"');
2546 print $formcompany->select_state($object->state_id, $object->country_code,
'state_id');
2548 print $object->state;
2554 print
"<tr>".
'<td>'.$langs->trans(
"PhonePro").
'</td>';
2556 print
img_picto(
'',
'phoning',
'class="pictofixedwidth"');
2557 if ($caneditfield && empty($object->ldap_sid)) {
2558 print
'<input type="text" name="office_phone" class="flat maxwidth200" value="'.$object->office_phone.
'">';
2560 print
'<input type="hidden" name="office_phone" value="'.$object->office_phone.
'">';
2561 print $object->office_phone;
2566 print
"<tr>".
'<td>'.$langs->trans(
"PhoneMobile").
'</td>';
2568 print
img_picto(
'',
'phoning_mobile',
'class="pictofixedwidth"');
2569 if ($caneditfield && empty($object->ldap_sid)) {
2570 print
'<input type="text" name="user_mobile" class="flat maxwidth200" value="'.$object->user_mobile.
'">';
2572 print
'<input type="hidden" name="user_mobile" value="'.$object->user_mobile.
'">';
2573 print $object->user_mobile;
2578 print
"<tr>".
'<td>'.$langs->trans(
"Fax").
'</td>';
2580 print
img_picto(
'',
'phoning_fax',
'class="pictofixedwidth"');
2581 if ($caneditfield && empty($object->ldap_sid)) {
2582 print
'<input type="text" name="office_fax" class="flat maxwidth200" value="'.$object->office_fax.
'">';
2584 print
'<input type="hidden" name="office_fax" value="'.$object->office_fax.
'">';
2585 print $object->office_fax;
2590 print
"<tr>".
'<td'.(!empty($conf->global->USER_MAIL_REQUIRED) ?
' class="fieldrequired"' :
'').
'>'.$langs->trans(
"EMail").
'</td>';
2592 print
img_picto(
'',
'object_email',
'class="pictofixedwidth"');
2593 if ($caneditfield && empty($object->ldap_sid)) {
2594 print
'<input class="minwidth100 maxwidth500 widthcentpercentminusx" type="text" name="email" class="flat" value="'.$object->email.
'">';
2596 print
'<input type="hidden" name="email" value="'.$object->email.
'">';
2597 print $object->email;
2602 foreach ($socialnetworks as $key => $value) {
2603 if ($value[
'active']) {
2604 print
'<tr><td>'.$langs->trans($value[
'label']).
'</td>';
2606 if (!empty($value[
'icon'])) {
2607 print
'<span class="fa '.$value[
'icon'].
' pictofixedwidth"></span>';
2609 if ($caneditfield && empty($object->ldap_sid)) {
2610 print
'<input type="text" name="'.$key.
'" class="flat maxwidth200" value="'.(isset($object->socialnetworks[$key])?$object->socialnetworks[$key]:
'').
'">';
2612 print
'<input type="hidden" name="'.$key.
'" value="'.$object->socialnetworks[$key].
'">';
2613 print $object->socialnetworks[$key];
2618 print
'<input type="hidden" name="'.$key.
'" value="'.(isset($object->socialnetworks[$key])?$object->socialnetworks[$key]:
'').
'">';
2623 print
'</table><hr><table class="border centpercent">';
2626 if (
isModEnabled(
'stock') && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE_USER)) {
2627 print
'<tr><td class="titlefield">'.$langs->trans(
"DefaultWarehouse").
'</td><td>';
2628 print $formproduct->selectWarehouses($object->fk_warehouse,
'fk_warehouse',
'warehouseopen', 1);
2629 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>';
2636 print
'<td class="titlefieldcreate">'.$langs->trans(
"AccountancyCode").
'</td>';
2638 if ($caneditfield) {
2639 print
'<input type="text" class="flat maxwidth300" name="accountancy_code" value="'.$object->accountancy_code.
'">';
2641 print
'<input type="hidden" name="accountancy_code" value="'.$object->accountancy_code.
'">';
2642 print $object->accountancy_code;
2650 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ColorUser").
'</td>';
2652 if ($caneditfield) {
2653 print $formother->selectColor(
GETPOSTISSET(
'color') ?
GETPOST(
'color',
'alphanohtml') : $object->color,
'color',
null, 1,
'',
'hideifnotset');
2655 print $formother->showColor($object->color,
'');
2662 print
'<td class="titlefieldcreate">'.$langs->trans(
"Photo").
'</td>';
2664 print
$form->showphoto(
'userphoto', $object, 60, 0, $caneditfield,
'photowithmargin',
'small', 1, 0,
'user', 1);
2669 if (
isModEnabled(
'categorie') && $user->hasRight(
"categorie",
"read")) {
2670 print
'<tr><td>'.$form->editfieldkey(
'Categories',
'usercats',
'', $object, 0).
'</td>';
2672 print
img_picto(
'',
'category',
'class="pictofixedwidth"');
2673 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_USER,
null,
null,
null,
null, 1);
2675 $cats = $c->containing($object->id, Categorie::TYPE_USER);
2676 $arrayselected = array();
2677 foreach ($cats as $cat) {
2678 $arrayselected[] = $cat->id;
2680 if ($caneditfield) {
2681 print
$form->multiselectarray(
'usercats', $cate_arbo, $arrayselected,
'', 0,
'', 0,
'90%');
2683 print
$form->showCategories($object->id, Categorie::TYPE_USER, 1);
2690 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";
2691 print
img_picto(
'',
'language',
'class="pictofixedwidth"').$formadmin->select_language($object->lang,
'default_lang', 0,
null,
'1', 0, 0,
'widthcentpercentminusx maxwidth300');
2697 print
'<tr><td>'.$langs->trans(
"Status").
'</td>';
2699 print $object->getLibStatut(4);
2704 print
'<tr><td>'.$langs->trans(
"LinkToCompanyContact").
'</td>';
2706 if ($object->socid > 0) {
2708 $societe->fetch($object->socid);
2709 print $societe->getNomUrl(1,
'');
2710 if ($object->contact_id) {
2712 $contact->fetch($object->contact_id);
2713 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>';
2716 print
'<span class="opacitymedium hideonsmartphone">'.$langs->trans(
"ThisUserIsNot").
'</span>';
2718 print
' <span class="opacitymedium hideonsmartphone">('.$langs->trans(
"UseTypeFieldToChange").
')</span>';
2725 $langs->load(
"members");
2726 print
'<tr><td>'.$langs->trans(
"LinkedToDolibarrMember").
'</td>';
2728 if ($object->fk_member) {
2730 $adh->fetch($object->fk_member);
2731 $adh->ref = $adh->login;
2732 print $adh->getNomUrl(1);
2734 print
'<span class="opacitymedium hideonsmartphone">'.$langs->trans(
"UserNotLinkedToMember").
'</span>';
2744 if (!method_exists($mc,
'formObjectOptions')) {
2745 if (empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && !$user->entity) {
2746 print
"<tr>".
'<td>'.$langs->trans(
"Entity").
'</td>';
2747 print
"<td>".$mc->select_entities($object->entity,
'entity',
'', 0, 1,
false,
false, 1);
2748 print
"</td></tr>\n";
2750 print
'<input type="hidden" name="entity" value="'.$conf->entity.
'" />';
2758 $reshook = $hookmanager->executeHooks(
'formObjectOptions',
$parameters, $object, $action);
2759 print $hookmanager->resPrint;
2760 if (empty($reshook)) {
2761 if ($caneditfield) {
2762 print $object->showOptionals($extrafields,
'edit');
2764 print $object->showOptionals($extrafields,
'view');
2769 print
'<tr><td class="tdtop">'.$langs->trans(
"Signature").
'</td>';
2771 if ($caneditfield) {
2772 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
2774 $doleditor =
new DolEditor(
'signature', $object->signature,
'', 138,
'dolibarr_notes',
'In',
false, $acceptlocallinktomedia, empty($conf->global->FCKEDITOR_ENABLE_USERSIGN) ? 0 : 1, ROWS_4,
'90%');
2775 print $doleditor->Create(1);
2787 print
'<table class="border centpercent">';
2793 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"PostOrFunction").
'</td>';
2795 if ($caneditfield) {
2796 print
'<input type="text" class="minwidth300 maxwidth500" name="job" value="'.dol_escape_htmltag($object->job).
'">';
2798 print
'<input type="hidden" name="job" value="'.dol_escape_htmltag($object->job).
'">';
2804 print
'<tr><td>'.$langs->trans(
"WeeklyHours").
'</td>';
2806 if ($caneditfield) {
2807 print
'<input size="8" type="text" name="weeklyhours" value="'.price2num(
GETPOST(
'weeklyhours') ?
GETPOST(
'weeklyhours') : $object->weeklyhours).
'">';
2815 if ((empty($user->socid) && in_array($id, $childids))
2816 || (
isModEnabled(
'salaries') && $user->hasRight(
"salaries",
"readall"))
2817 || (
isModEnabled(
'hrm') && $user->hasRight(
"hrm",
"employee",
"read"))) {
2818 $langs->load(
"salaries");
2821 print
'<tr><td>'.$langs->trans(
"Salary").
'</td>';
2823 print
img_picto(
'',
'salary',
'class="pictofixedwidth paddingright"').
'<input size="8" type="text" name="salary" value="'.
price2num(
GETPOST(
'salary') ?
GETPOST(
'salary') : $object->salary).
'">';
2829 $text = $langs->trans(
"THM");
2830 print
$form->textwithpicto($text, $langs->trans(
"THMDescription"), 1,
'help',
'classthm');
2833 if ($caneditfield) {
2834 print
'<input size="8" type="text" name="thm" value="'.price2num(
GETPOST(
'thm') ?
GETPOST(
'thm') : $object->thm).
'">';
2836 print ($object->thm !=
'' ?
price($object->thm,
'', $langs, 1, -1, -1, $conf->currency) :
'');
2843 $text = $langs->trans(
"TJM");
2844 print
$form->textwithpicto($text, $langs->trans(
"TJMDescription"), 1,
'help',
'classthm');
2847 if ($caneditfield) {
2848 print
'<input size="8" type="text" name="tjm" value="'.price2num(
GETPOST(
'tjm') ?
GETPOST(
'tjm') : $object->tjm).
'">';
2850 print ($object->tjm !=
'' ?
price($object->tjm,
'', $langs, 1, -1, -1, $conf->currency) :
'');
2857 print
'<tr><td>'.$langs->trans(
"DateEmployment").
'</td>';
2859 if ($caneditfield) {
2860 print
$form->selectDate($dateemployment ? $dateemployment : $object->dateemployment,
'dateemployment', 0, 0, 1,
'formdateemployment', 1, 1, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"from"));
2865 if ($dateemployment && $dateemploymentend) {
2869 if ($caneditfield) {
2870 print
$form->selectDate($dateemploymentend ? $dateemploymentend : $object->dateemploymentend,
'dateemploymentend', 0, 0, 1,
'formdateemploymentend', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"));
2878 print
'<tr><td>'.$langs->trans(
"DateOfBirth").
'</td>';
2880 if ($caneditfield) {
2881 echo
$form->selectDate($dateofbirth ? $dateofbirth : $object->birth,
'dateofbirth', 0, 0, 1,
'updateuser', 1, 0, 0,
'',
'',
'',
'', 1,
'',
'',
'tzserver');
2892 print
'<div class="center">';
2893 print
'<input value="'.$langs->trans(
"Save").
'" class="button button-save" type="submit" name="save">';
2894 print
' ';
2895 print
'<input value="'.$langs->trans(
"Cancel").
'" class="button button-cancel" type="submit" name="cancel">';
2901 if ($action !=
'edit' && $action !=
'presend') {
2902 print
'<div class="fichecenter"><div class="fichehalfleft">';
2907 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".$object->id;
2908 $genallowed = $user->hasRight(
"user",
"user",
"read");
2909 $delallowed = $user->hasRight(
"user",
"user",
"write");
2911 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);
2912 $somethingshown = $formfile->numoffiles;
2915 $linktoelem =
$form->showLinkToObjectBlock($object,
null,
null);
2916 $somethingshown =
$form->showLinkedObjectBlock($object, $linktoelem);
2918 print
'</div><div class="fichehalfright">';
2921 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
2923 $somethingshown =
$formactions->showactions($object,
'user', $socid, 1,
'listactions', 0,
'',
'', $object->id);
2925 print
'</div></div>';
2928 if (
isModEnabled(
'ldap') && !empty($object->ldap_sid)) {
2935 include_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
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.
if(isModEnabled('facture') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $sql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
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)
newToken()
Return the value of token currently saved into session with name 'newtoken'.
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
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.
isModEnabled($module)
Is Dolibarr module enabled.
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.