39require
'../main.inc.php';
40require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/user/class/usergroup.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
43require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
44require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
45require_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
46require_once DOL_DOCUMENT_ROOT.
'/core/lib/usergroups.lib.php';
47require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
48require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
49require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
50require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
51require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
52require_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
53if (isModEnabled(
'ldap')) {
54 require_once DOL_DOCUMENT_ROOT.
'/core/class/ldap.class.php';
56if (isModEnabled(
'adherent')) {
57 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
59if (isModEnabled(
'categorie')) {
60 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
62if (isModEnabled(
'stock')) {
63 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
67$langs->loadLangs(array(
'users',
'companies',
'ldap',
'admin',
'hrm',
'stocks',
'other'));
70$action =
GETPOST(
'action',
'aZ09');
71$mode =
GETPOST(
'mode',
'alpha');
72$confirm =
GETPOST(
'confirm',
'alpha');
73$group =
GETPOST(
"group",
"int", 3);
74$cancel =
GETPOST(
'cancel',
'alpha');
75$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'useracard';
77if (empty($id) && $action !=
'create') {
82$dateemploymentend =
dol_mktime(0, 0, 0,
GETPOST(
'dateemploymentendmonth',
'int'),
GETPOST(
'dateemploymentendday',
'int'),
GETPOST(
'dateemploymentendyear',
'int'));
83$datestartvalidity =
dol_mktime(0, 0, 0,
GETPOST(
'datestartvaliditymonth',
'int'),
GETPOST(
'datestartvalidityday',
'int'),
GETPOST(
'datestartvalidityyear',
'int'));
84$dateendvalidity =
dol_mktime(0, 0, 0,
GETPOST(
'dateendvaliditymonth',
'int'),
GETPOST(
'dateendvalidityday',
'int'),
GETPOST(
'dateendvalidityyear',
'int'));
87$childids = $user->getAllChildIds(1);
89$object =
new User($db);
93$extrafields->fetch_name_optionals_label($object->table_element);
98$hookmanager->initHooks(array(
'usercard',
'globalcard'));
105 $res = $object->fetch($id,
'',
'', 1);
110if ($user->socid > 0) {
111 $socid = $user->socid;
117$canadduser = (!empty($user->admin) || $user->hasRight(
"user",
"user",
"write"));
118$canreaduser = (!empty($user->admin) || $user->hasRight(
"user",
"user",
"read"));
119$canedituser = (!empty($user->admin) || $user->hasRight(
"user",
"user",
"write"));
120$candisableuser = (!empty($user->admin) || $user->hasRight(
"user",
"user",
"delete"));
121$canreadgroup = $canreaduser;
122$caneditgroup = $canedituser;
124 $canreadgroup = (!empty($user->admin) || $user->hasRight(
"user",
"group_advance",
"read"));
125 $caneditgroup = (!empty($user->admin) || $user->hasRight(
"user",
"group_advance",
"write"));
128if ($user->id != $id && !$canreaduser) {
135 $canedituser = (($user->id == $id) && $user->hasRight(
"user",
"self",
"write")) || (($user->id != $id) && $user->hasRight(
"user",
"user",
"write"));
136 $caneditfield = ((($user->id == $id) && $user->hasRight(
"user",
"self",
"write")) || (($user->id != $id) && $user->hasRight(
"user",
"user",
"write")));
137 $caneditpasswordandsee = ((($user->id == $id) && $user->hasRight(
"user",
"self",
"password")) || (($user->id != $id) && $user->hasRight(
"user",
"user",
"password") && $user->admin));
138 $caneditpasswordandsend = ((($user->id == $id) && $user->hasRight(
"user",
"self",
"password")) || (($user->id != $id) && $user->hasRight(
"user",
"user",
"password")));
146$parameters = array(
'id' => $id,
'socid' => $socid,
'group' => $group,
'caneditgroup' => $caneditgroup);
147$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
152if (empty($reshook)) {
153 $backurlforlist = DOL_URL_ROOT.
'/user/list.php';
155 if (empty($backtopage) || ($cancel && empty($id))) {
156 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
157 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
158 $backtopage = $backurlforlist;
160 $backtopage = DOL_URL_ROOT.
'/user/card.php?id='.((!empty($id) && $id > 0) ? $id :
'__ID__');
166 if (!empty($backtopageforcancel)) {
167 header(
"Location: ".$backtopageforcancel);
169 } elseif (!empty($backtopage)) {
170 header(
"Location: ".$backtopage);
176 if ($action ==
'confirm_disable' && $confirm ==
"yes" && $candisableuser) {
177 if ($id != $user->id) {
179 if ($object->admin && empty($user->admin)) {
182 setEventMessages($langs->trans(
"OnlyAdminUsersCanDisableAdminUsers"),
null,
'errors');
184 $object->setstatus(0);
185 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$id);
191 if ($action ==
'confirm_enable' && $confirm ==
"yes" && $candisableuser) {
194 if ($id != $user->id) {
197 if (!empty($conf->file->main_limit_users)) {
198 $nb = $object->getNbOfUsers(
"active");
199 if ($nb >= $conf->file->main_limit_users) {
201 setEventMessages($langs->trans(
"YourQuotaOfUsersIsReached"),
null,
'errors');
206 $object->setstatus(1);
207 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$id);
213 if ($action ==
'confirm_delete' && $confirm ==
"yes" && $candisableuser) {
214 if ($id != $user->id) {
215 if (!GETPOSTISSET(
'token')) {
216 print
'Error, token required for this critical operation';
220 $object =
new User($db);
222 $object->oldcopy = clone $object;
224 $result = $object->delete($user);
226 $langs->load(
"errors");
230 header(
"Location: ".DOL_URL_ROOT.
"/user/list.php?restore_lastsearch_values=1");
237 if ($action ==
'add' && $canadduser) {
251 if (!empty($conf->file->main_limit_users)) {
252 $nb = $object->getNbOfUsers(
"active");
253 if ($nb >= $conf->file->main_limit_users) {
255 setEventMessages($langs->trans(
"YourQuotaOfUsersIsReached"),
null,
'errors');
261 $object->civility_code =
GETPOST(
"civility_code",
'aZ09');
262 $object->lastname =
GETPOST(
"lastname",
'alphanohtml');
263 $object->firstname =
GETPOST(
"firstname",
'alphanohtml');
264 $object->ref_employee =
GETPOST(
"ref_employee",
'alphanohtml');
265 $object->national_registration_number =
GETPOST(
"national_registration_number",
'alphanohtml');
266 $object->login =
GETPOST(
"login",
'alphanohtml');
267 $object->api_key =
GETPOST(
"api_key",
'alphanohtml');
268 $object->gender =
GETPOST(
"gender",
'aZ09');
270 $object->address =
GETPOST(
'address',
'alphanohtml');
271 $object->zip =
GETPOST(
'zipcode',
'alphanohtml');
272 $object->town =
GETPOST(
'town',
'alphanohtml');
273 $object->country_id =
GETPOSTINT(
'country_id');
275 $object->office_phone =
GETPOST(
"office_phone",
'alphanohtml');
276 $object->office_fax =
GETPOST(
"office_fax",
'alphanohtml');
277 $object->user_mobile =
GETPOST(
"user_mobile",
'alphanohtml');
279 if (isModEnabled(
'socialnetworks')) {
280 $object->socialnetworks = array();
281 foreach ($socialnetworks as $key => $value) {
282 if (
GETPOST($key,
'alphanohtml')) {
283 $object->socialnetworks[$key] =
GETPOST($key,
'alphanohtml');
288 $object->email = preg_replace(
'/\s+/',
'',
GETPOST(
"email",
'alphanohtml'));
289 $object->job =
GETPOST(
"job",
'alphanohtml');
290 $object->signature =
GETPOST(
"signature",
'restricthtml');
291 $object->accountancy_code =
GETPOST(
"accountancy_code",
'alphanohtml');
292 $object->note_public =
GETPOST(
"note_public",
'restricthtml');
293 $object->note_private =
GETPOST(
"note_private",
'restricthtml');
294 $object->ldap_sid =
GETPOST(
"ldap_sid",
'alphanohtml');
295 $object->fk_user =
GETPOST(
"fk_user",
'int') > 0 ?
GETPOST(
"fk_user",
'int') : 0;
296 $object->fk_user_expense_validator =
GETPOST(
"fk_user_expense_validator",
'int') > 0 ?
GETPOST(
"fk_user_expense_validator",
'int') : 0;
297 $object->fk_user_holiday_validator =
GETPOST(
"fk_user_holiday_validator",
'int') > 0 ?
GETPOST(
"fk_user_holiday_validator",
'int') : 0;
298 $object->employee =
GETPOST(
'employee',
'alphanohtml');
300 $object->thm =
GETPOST(
"thm",
'alphanohtml') !=
'' ?
GETPOST(
"thm",
'alphanohtml') :
'';
302 $object->tjm =
GETPOST(
"tjm",
'alphanohtml') !=
'' ?
GETPOST(
"tjm",
'alphanohtml') :
'';
304 $object->salary =
GETPOST(
"salary",
'alphanohtml') !=
'' ?
GETPOST(
"salary",
'alphanohtml') :
'';
305 $object->salary =
price2num($object->salary);
306 $object->salaryextra =
GETPOST(
"salaryextra",
'alphanohtml') !=
'' ?
GETPOST(
"salaryextra",
'alphanohtml') :
'';
307 $object->weeklyhours =
GETPOST(
"weeklyhours",
'alphanohtml') !=
'' ?
GETPOST(
"weeklyhours",
'alphanohtml') :
'';
309 $object->color =
GETPOST(
"color",
'alphanohtml') !=
'' ?
GETPOST(
"color",
'alphanohtml') :
'';
311 $object->dateemployment = $dateemployment;
312 $object->dateemploymentend = $dateemploymentend;
313 $object->datestartvalidity = $datestartvalidity;
314 $object->dateendvalidity = $dateendvalidity;
315 $object->birth = $dateofbirth;
317 $object->fk_warehouse =
GETPOSTINT(
'fk_warehouse');
319 $object->lang =
GETPOST(
'default_lang',
'aZ09');
322 $ret = $extrafields->setOptionalsFromPost(
null, $object);
328 $entity =
GETPOST(
'entity',
'int');
329 if (isModEnabled(
'multicompany')) {
330 if (
GETPOST(
'superadmin',
'int')) {
336 $object->entity = ($entity ==
'' ? 1 : $entity);
340 $object->entity = ($entity ==
'' ? 1 : $entity);
348 $id = $object->create($user);
351 if (
GETPOST(
'password',
'none')) {
352 $resPass = $object->setPassword($user,
GETPOST(
'password',
'none'));
354 if (is_int($resPass) && $resPass < 0) {
355 $langs->load(
"errors");
360 if (isModEnabled(
"categorie")) {
362 $usercats =
GETPOST(
'usercats',
'array');
363 $object->setCategories($usercats);
367 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$id);
371 $langs->load(
"errors");
380 if (($action ==
'addgroup' || $action ==
'removegroup') && $caneditgroup) {
383 $editgroup->fetch($group);
384 $editgroup->oldcopy = clone $editgroup;
388 if ($action ==
'addgroup') {
389 $result = $object->SetInGroup($group, $editgroup->entity);
391 if ($action ==
'removegroup') {
392 $result = $object->RemoveFromGroup($group, $editgroup->entity);
403 if ($action ==
'update' && $canedituser) {
404 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
409 if (!
GETPOST(
"lastname",
'alpha')) {
414 if (!
GETPOST(
"login",
'alpha')) {
423 $object->oldcopy = clone $object;
427 $object->civility_code =
GETPOST(
"civility_code",
'aZ09');
428 $object->lastname =
GETPOST(
"lastname",
'alphanohtml');
429 $object->firstname =
GETPOST(
"firstname",
'alphanohtml');
431 if (GETPOSTISSET(
"ref_employee")) {
432 $object->ref_employee =
GETPOST(
"ref_employee",
'alphanohtml');
435 if (GETPOSTISSET(
"national_registration_number")) {
436 $object->national_registration_number =
GETPOST(
"national_registration_number",
'alphanohtml');
438 $object->gender =
GETPOST(
"gender",
'aZ09');
439 if ($caneditpasswordandsee) {
440 $object->pass =
GETPOST(
"password",
'none');
442 if ($caneditpasswordandsee || $user->hasRight(
"api",
"apikey",
"generate")) {
443 $object->api_key = (
GETPOST(
"api_key",
'alphanohtml')) ?
GETPOST(
"api_key",
'alphanohtml') : $object->api_key;
445 if (!empty($user->admin) && $user->id != $id) {
448 $object->admin =
GETPOST(
"admin",
"int");
450 if ($user->admin && !$object->ldap_sid) {
451 $object->login =
GETPOST(
"login",
'alphanohtml');
453 $object->address =
GETPOST(
'address',
'alphanohtml');
454 $object->zip =
GETPOST(
'zipcode',
'alphanohtml');
455 $object->town =
GETPOST(
'town',
'alphanohtml');
456 $object->country_id =
GETPOST(
'country_id',
'int');
457 $object->state_id =
GETPOST(
'state_id',
'int');
458 $object->office_phone =
GETPOST(
"office_phone",
'alphanohtml');
459 $object->office_fax =
GETPOST(
"office_fax",
'alphanohtml');
460 $object->user_mobile =
GETPOST(
"user_mobile",
'alphanohtml');
462 if (isModEnabled(
'socialnetworks')) {
463 $object->socialnetworks = array();
464 foreach ($socialnetworks as $key => $value) {
465 if (
GETPOST($key,
'alphanohtml')) {
466 $object->socialnetworks[$key] =
GETPOST($key,
'alphanohtml');
471 $object->email = preg_replace(
'/\s+/',
'',
GETPOST(
"email",
'alphanohtml'));
472 $object->job =
GETPOST(
"job",
'alphanohtml');
473 $object->signature =
GETPOST(
"signature",
'restricthtml');
474 $object->accountancy_code =
GETPOST(
"accountancy_code",
'alphanohtml');
475 $object->openid =
GETPOST(
"openid",
'alphanohtml');
476 $object->fk_user =
GETPOST(
"fk_user",
'int') > 0 ?
GETPOST(
"fk_user",
'int') : 0;
477 $object->fk_user_expense_validator =
GETPOST(
"fk_user_expense_validator",
'int') > 0 ?
GETPOST(
"fk_user_expense_validator",
'int') : 0;
478 $object->fk_user_holiday_validator =
GETPOST(
"fk_user_holiday_validator",
'int') > 0 ?
GETPOST(
"fk_user_holiday_validator",
'int') : 0;
479 $object->employee =
GETPOST(
'employee',
'int');
481 $object->thm =
GETPOST(
"thm",
'alphanohtml') !=
'' ?
GETPOST(
"thm",
'alphanohtml') :
'';
483 $object->tjm =
GETPOST(
"tjm",
'alphanohtml') !=
'' ?
GETPOST(
"tjm",
'alphanohtml') :
'';
485 $object->salary =
GETPOST(
"salary",
'alphanohtml') !=
'' ?
GETPOST(
"salary",
'alphanohtml') :
'';
486 $object->salary =
price2num($object->salary);
487 $object->salaryextra =
GETPOST(
"salaryextra",
'alphanohtml') !=
'' ?
GETPOST(
"salaryextra",
'alphanohtml') :
'';
488 $object->salaryextra =
price2num($object->salaryextra);
489 $object->weeklyhours =
GETPOST(
"weeklyhours",
'alphanohtml') !=
'' ?
GETPOST(
"weeklyhours",
'alphanohtml') :
'';
490 $object->weeklyhours =
price2num($object->weeklyhours);
492 $object->color =
GETPOST(
"color",
'alphanohtml') !=
'' ?
GETPOST(
"color",
'alphanohtml') :
'';
493 $object->dateemployment = $dateemployment;
494 $object->dateemploymentend = $dateemploymentend;
495 $object->datestartvalidity = $datestartvalidity;
496 $object->dateendvalidity = $dateendvalidity;
497 $object->birth = $dateofbirth;
499 if (isModEnabled(
'stock')) {
500 $object->fk_warehouse =
GETPOST(
'fk_warehouse',
'int');
503 $object->lang =
GETPOST(
'default_lang',
'aZ09');
506 if (isModEnabled(
'multicompany') && empty($user->entity) && !empty($user->admin)) {
507 if (
GETPOST(
'superadmin',
'int')) {
514 $object->entity = (GETPOSTISSET(
'entity') ?
GETPOSTINT(
'entity') : $object->entity);
520 $ret = $extrafields->setOptionalsFromPost(
null, $object,
'@GETPOSTISSET');
528 if (!empty($_FILES[
'photo'][
'name'])) {
534 $langs->load(
"errors");
536 dol_syslog($langs->transnoentities(
"ErrorBadImageFormat"), LOG_INFO);
541 $passwordismodified = 0;
542 if (!empty($object->pass)) {
543 if ($object->pass != $object->pass_indatabase && !
dol_verifyHash($object->pass, $object->pass_indatabase_crypted)) {
544 $passwordismodified = 1;
548 $ret = $object->update($user);
551 if ($db->errno() ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
552 $langs->load(
"errors");
553 setEventMessages($langs->trans(
"ErrorUpdateCanceledDueToDuplicatedUniqueValue", $object->login),
null,
'errors');
561 if (!$error && GETPOSTISSET(
'contactid')) {
562 $contactid =
GETPOST(
'contactid',
'int');
563 $socid =
GETPOST(
'socid',
'int');
565 if ($contactid > 0) {
567 $contact->fetch($contactid);
569 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user";
570 $sql .=
" SET fk_socpeople=".((int) $contactid);
571 if (!empty($contact->socid)) {
572 $sql .=
", fk_soc=".((int) $contact->socid);
573 } elseif ($socid > 0) {
574 $sql .=
", fk_soc = null";
575 setEventMessages($langs->trans(
"WarningUserDifferentContactSocid"),
null,
'warnings');
577 $sql .=
" WHERE rowid = ".((int) $object->id);
578 } elseif ($socid > 0) {
579 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user";
580 $sql .=
" SET fk_socpeople=NULL, fk_soc=".((int) $socid);
581 $sql .=
" WHERE rowid = ".((int) $object->id);
583 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user";
584 $sql .=
" SET fk_socpeople=NULL, fk_soc=NULL";
585 $sql .=
" WHERE rowid = ".((int) $object->id);
588 $resql = $db->query($sql);
595 if (!$error && !count($object->errors)) {
596 if (!empty($object->oldcopy->photo) && (
GETPOST(
'deletephoto') || ($object->photo != $object->oldcopy->photo))) {
597 $fileimg = $conf->user->dir_output.
'/'.
get_exdir(0, 0, 0, 0, $object,
'user').
'photos/'.$object->oldcopy->photo;
600 $dirthumbs = $conf->user->dir_output.
'/'.
get_exdir(0, 0, 0, 0, $object,
'user').
'photos/thumbs';
604 if (isset($_FILES[
'photo'][
'tmp_name']) && trim($_FILES[
'photo'][
'tmp_name'])) {
605 $dir = $conf->user->dir_output.
'/'.
get_exdir(0, 0, 0, 1, $object,
'user').
'/photos';
611 $result =
dol_move_uploaded_file($_FILES[
'photo'][
'tmp_name'], $newfile, 1, 0, $_FILES[
'photo'][
'error']);
613 if (!($result > 0)) {
617 $object->addThumbs($newfile);
621 $langs->load(
"errors");
622 setEventMessages($langs->trans(
"ErrorFailedToCreateDir", $dir), $mesgs,
'errors');
627 if (!$error && !count($object->errors)) {
629 $categories =
GETPOST(
'usercats',
'array');
630 $object->setCategories($categories);
633 if (!$error && !count($object->errors)) {
637 $login = $_SESSION[
"dol_login"];
638 if ($login && $login == $object->oldcopy->login && $object->oldcopy->login != $object->login) {
640 $langs->load(
"errors");
641 setEventMessages($langs->transnoentitiesnoconv(
"WarningYourLoginWasModifiedPleaseLogin"),
null,
'warnings');
643 if ($passwordismodified && $object->login == $user->login) {
645 $langs->load(
"errors");
646 setEventMessages($langs->transnoentitiesnoconv(
"WarningYourPasswordWasModifiedPleaseLogin"),
null,
'warnings');
647 header(
"Location: ".DOL_URL_ROOT.
'/user/card.php?id='.$object->id);
655 if ($caneditpasswordandsee) {
656 dol_syslog(
"Not allowed to change fields, only password");
660 if (
GETPOST(
"password",
"none")) {
661 $object->oldcopy = clone $object;
663 $ret = $object->setPassword($user,
GETPOST(
"password",
"none"));
664 if (is_int($ret) && $ret < 0) {
673 if ((($action ==
'confirm_password' && $confirm ==
'yes' && $caneditpasswordandsee)
674 || ($action ==
'confirm_passwordsend' && $confirm ==
'yes' && $caneditpasswordandsend))
678 $newpassword = $object->setPassword($user,
'');
679 if (is_int($newpassword) && $newpassword < 0) {
681 setEventMessages($langs->trans(
"ErrorFailedToSetNewPassword"),
null,
'errors');
684 if ($action ==
'confirm_passwordsend' && $confirm ==
'yes') {
685 if ($object->send_password($user, $newpassword) > 0) {
686 setEventMessages($langs->trans(
"PasswordChangedAndSentTo", $object->email),
null,
'mesgs');
691 setEventMessages($langs->trans(
"PasswordChangedTo", $newpassword),
null,
'warnings');
697 if ($action ==
'adduserldap' && $canadduser) {
698 $selecteduser =
GETPOST(
'users');
700 $required_fields = array(
716 if (isModEnabled(
'socialnetworks')) {
717 $arrayofsocialnetworks = array(
'skype',
'twitter',
'facebook',
'linkedin');
718 foreach ($arrayofsocialnetworks as $socialnetwork) {
724 $result = $ldap->connect_bind();
727 $required_fields = array_unique(array_values(array_filter($required_fields,
"dol_validElement")));
732 if (is_array($ldapusers)) {
733 foreach ($ldapusers as $key => $attribute) {
746 if (isModEnabled(
'socialnetworks')) {
747 $arrayofsocialnetworks = array(
'skype',
'twitter',
'facebook',
'linkedin');
748 foreach ($arrayofsocialnetworks as $socialnetwork) {
749 $ldap_social[$socialnetwork] = $attribute[
getDolGlobalString(
'LDAP_FIELD_'.strtoupper($socialnetwork))];
760 $triggersendname =
'USER_SENTBYMAIL';
762 $mode =
'emailfromuser';
763 $trackid =
'use'.$id;
764 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
767 $upload_dir = $conf->user->dir_output;
768 $permissiontoadd = $user->hasRight(
"user",
"user",
"write");
769 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
777$form =
new Form($db);
782if (isModEnabled(
'stock')) {
786if ($object->id > 0) {
787 $person_name = !empty($object->firstname) ? $object->lastname.
", ".$object->firstname : $object->lastname;
788 $title = $person_name.
" - ".$langs->trans(
'Card');
790 if (
GETPOST(
'employee',
'alphanohtml')) {
791 $title = $langs->trans(
"NewEmployee");
793 $title = $langs->trans(
"NewUser");
801if ($action ==
'create' || $action ==
'adduserldap') {
804 print
'<span class="opacitymedium">'.$langs->trans(
"CreateInternalUserDesc").
"</span><br>\n";
813 $result = $ldap->connect_bind();
815 $required_fields = array(
835 $required_fields = array_unique(array_values(array_filter($required_fields,
"dol_validElement")));
840 if (is_array($ldapusers)) {
841 foreach ($ldapusers as $key => $ldapuser) {
844 foreach ($required_fields as $value) {
846 $label .= $value.
"=******* ";
848 $label .= $value.
"=".$ldapuser[$value].
" ";
851 $liste[$key] = $label;
861 print
"\n\n<!-- Form liste LDAP debut -->\n";
863 print
'<form name="add_user_ldap" action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
864 print
'<input type="hidden" name="token" value="'.newToken().
'">';
865 print
'<table class="border centpercent"><tr>';
866 print
'<td width="160">';
867 print $langs->trans(
"LDAPUsers");
870 print
'<input type="hidden" name="action" value="adduserldap">';
871 if (is_array($liste) && count($liste)) {
872 print $form->selectarray(
'users', $liste,
'', 1, 0, 0,
'', 0, 0, 0,
'',
'maxwidth500');
875 print
'</td><td class="center">';
876 print
'<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans(
'Get')).
'"'.(count($liste) ?
'' :
' disabled').
'>';
877 print
'</td></tr></table>';
880 print
"\n<!-- Form liste LDAP fin -->\n\n";
885 print
'<form action="'.$_SERVER[
'PHP_SELF'].
'" method="POST" name="createuser">';
886 print
'<input type="hidden" name="token" value="'.newToken().
'">';
887 print
'<input type="hidden" name="action" value="add">';
888 if (!empty($ldap_sid)) {
889 print
'<input type="hidden" name="ldap_sid" value="'.dol_escape_htmltag($ldap_sid).
'">';
891 print
'<input type="hidden" name="entity" value="'.$conf->entity.
'">';
897 print
'<table class="border centpercent">';
900 print
'<tr><td><label for="civility_code">'.$langs->trans(
"UserTitle").
'</label></td><td>';
901 print $formcompany->select_civility(GETPOSTISSET(
"civility_code") ?
GETPOST(
"civility_code",
'aZ09') : $object->civility_code,
'civility_code');
906 print
'<td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans(
"Lastname").
'</span></td>';
908 if (!empty($ldap_lastname)) {
909 print
'<input type="hidden" id="lastname" name="lastname" value="'.dol_escape_htmltag($ldap_lastname).
'">';
910 print $ldap_lastname;
912 print
'<input class="minwidth100 maxwidth150onsmartphone createloginauto" type="text" id="lastname" name="lastname" value="'.dol_escape_htmltag(
GETPOST(
'lastname',
'alphanohtml')).
'">';
917 print
'<tr><td>'.$langs->trans(
"Firstname").
'</td>';
919 if (!empty($ldap_firstname)) {
920 print
'<input type="hidden" name="firstname" value="'.dol_escape_htmltag($ldap_firstname).
'">';
921 print $ldap_firstname;
923 print
'<input id="firstname" class="minwidth100 maxwidth150onsmartphone createloginauto" type="text" name="firstname" value="'.dol_escape_htmltag(
GETPOST(
'firstname',
'alphanohtml')).
'">';
928 print
'<tr><td><span class="fieldrequired">'.$langs->trans(
"Login").
'</span></td>';
930 if (!empty($ldap_login)) {
931 print
'<input type="hidden" name="login" value="'.dol_escape_htmltag($ldap_login).
'">';
933 } elseif (!empty($ldap_loginsmb)) {
934 print
'<input type="hidden" name="login" value="'.dol_escape_htmltag($ldap_loginsmb).
'">';
935 print $ldap_loginsmb;
937 print
'<input id="login" class="maxwidth200 maxwidth150onsmartphone" maxsize="24" type="text" name="login" value="'.dol_escape_htmltag(
GETPOST(
'login',
'alphanohtml')).
'">';
941 if (!empty($conf->use_javascript_ajax)) {
943 jQuery(document).ready(function() {
944 $(".createloginauto").on("change", function(){
945 lastname = $("#lastname").val();
946 firstname = $("#firstname").val();
947 if($(this).attr("id") == "firstname"){
948 firstname = firstname.toLowerCase();
949 firstname = firstname[0];
951 lastname = lastname.toLowerCase();
952 console.log("We create a login from firstname and lastname");
953 $("#login").val(firstname+lastname);
959 $generated_password =
'';
960 if (empty($ldap_sid)) {
963 $password = (GETPOSTISSET(
'password') ?
GETPOST(
'password') : $generated_password);
966 if (!empty($user->admin)) {
967 print
'<tr><td>'.$form->textwithpicto($langs->trans(
"Administrator"), $langs->trans(
"AdministratorDesc"), 1,
'star').
'</td>';
969 print $form->selectyesno(
'admin',
GETPOST(
'admin'), 1,
false, 0, 1);
971 if (isModEnabled(
'multicompany') && !$user->entity) {
972 if (!empty($conf->use_javascript_ajax)) {
973 print
'<script type="text/javascript">
975 $("select[name=admin]").change(function() {
976 if ( $(this).val() == 0 ) {
977 $("input[name=superadmin]")
978 .prop("disabled", true)
979 .prop("checked", false);
980 $("select[name=entity]")
981 .prop("disabled", false);
983 $("input[name=superadmin]")
984 .prop("disabled", false);
987 $("input[name=superadmin]").change(function() {
988 if ( $(this).is(":checked") ) {
989 $("select[name=entity]")
990 .prop("disabled", true);
992 $("select[name=entity]")
993 .prop("disabled", false);
999 $checked = (
GETPOST(
'superadmin',
'int') ?
' checked' :
'');
1000 $disabled = (
GETPOST(
'superadmin',
'int') ?
'' :
' disabled');
1001 print
'<input type="checkbox" name="superadmin" id="superadmin" value="1"'.$checked.$disabled.
' /> <label for="superadmin">'.$langs->trans(
"SuperAdministrator").
'</span>';
1003 print
"</td></tr>\n";
1007 print
'<tr><td>'.$langs->trans(
"Gender").
'</td>';
1009 $arraygender = array(
'man'=>$langs->trans(
"Genderman"),
'woman'=>$langs->trans(
"Genderwoman"),
'other'=>$langs->trans(
"Genderother"));
1010 print $form->selectarray(
'gender', $arraygender,
GETPOST(
'gender'), 1);
1014 $defaultemployee =
'1';
1016 print
'<td>'.$langs->trans(
'Employee').
'</td><td>';
1017 print
'<input type="checkbox" name="employee" value="1"'.(GETPOST(
'employee') ==
'1' ?
' checked="checked"' : (($defaultemployee && !GETPOSTISSET(
'login')) ?
' checked="checked"' :
'')).
'>';
1022 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"HierarchicalResponsible").
'</td>';
1024 print
img_picto(
'',
'user',
'class="pictofixedwidth"').$form->select_dolusers($object->fk_user,
'fk_user', 1, array($object->id), 0,
'', 0, $conf->entity, 0, 0,
'', 0,
'',
'maxwidth300 widthcentpercentminusx');
1029 if (isModEnabled(
'expensereport')) {
1030 print
'<tr><td class="titlefieldcreate">';
1031 $text = $langs->trans(
"ForceUserExpenseValidator");
1032 print $form->textwithpicto($text, $langs->trans(
"ValidatorIsSupervisorByDefault"), 1,
'help');
1035 print
img_picto(
'',
'user',
'class="pictofixedwidth"').$form->select_dolusers($object->fk_user_expense_validator,
'fk_user_expense_validator', 1, array($object->id), 0,
'', 0, $conf->entity, 0, 0,
'', 0,
'',
'maxwidth300 widthcentpercentminusx');
1041 if (isModEnabled(
'holiday')) {
1042 print
'<tr><td class="titlefieldcreate">';
1043 $text = $langs->trans(
"ForceUserHolidayValidator");
1044 print $form->textwithpicto($text, $langs->trans(
"ValidatorIsSupervisorByDefault"), 1,
'help');
1047 print
img_picto(
'',
'user',
'class="pictofixedwidth"').$form->select_dolusers($object->fk_user_holiday_validator,
'fk_user_holiday_validator', 1, array($object->id), 0,
'', 0, $conf->entity, 0, 0,
'', 0,
'',
'maxwidth300 widthcentpercentminusx');
1053 print
'<tr><td>'.$langs->trans(
"ExternalUser").
' ?</td>';
1055 print $form->textwithpicto($langs->trans(
"Internal"), $langs->trans(
"InternalExternalDesc"), 1,
'help',
'', 0, 2);
1059 print
'</table><hr><table class="border centpercent">';
1063 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"RangeOfLoginValidity").
'</td>';
1065 print $form->selectDate($datestartvalidity,
'datestartvalidity', 0, 0, 1,
'formdatestartvalidity', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"from"));
1069 print $form->selectDate($dateendvalidity,
'dateendvalidity', 0, 0, 1,
'formdateendvalidity', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"));
1074 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Password").
'</td>';
1077 if (preg_match(
'/ldap/', $dolibarr_main_authentication)) {
1078 $valuetoshow .= ($valuetoshow ?
' + ' :
'').$langs->trans(
"PasswordOfUserInLDAP").
' (hidden)';
1080 if (preg_match(
'/http/', $dolibarr_main_authentication)) {
1081 $valuetoshow .= ($valuetoshow ?
' + ' :
'').$langs->trans(
"HTTPBasicPassword");
1083 if (preg_match(
'/dolibarr/', $dolibarr_main_authentication) || preg_match(
'/forceuser/', $dolibarr_main_authentication)) {
1084 if (!empty($ldap_pass)) {
1085 $valuetoshow .= ($valuetoshow ?
' + ' :
'').
'<input type="hidden" name="password" value="'.
dol_escape_htmltag($ldap_pass).
'">';
1086 $valuetoshow .= preg_replace(
'/./i',
'*', $ldap_pass);
1089 $valuetoshow .= ($valuetoshow ?
' + '.$langs->trans(
"DolibarrPassword") :
'').
'<input class="minwidth300 maxwidth400 widthcentpercentminusx" maxlength="128" type="text" id="password" name="password" value="'.
dol_escape_htmltag($password).
'" autocomplete="new-password">';
1090 if (!empty($conf->use_javascript_ajax)) {
1091 $valuetoshow .=
img_picto($langs->trans(
'Generate'),
'refresh',
'id="generate_password" class="linkobject paddingleft"');
1097 $parameters = array(
'valuetoshow' => $valuetoshow,
'password' => $password);
1098 $reshook = $hookmanager->executeHooks(
'printUserPasswordField', $parameters, $object, $action);
1100 $valuetoshow = $hookmanager->resPrint;
1102 $valuetoshow .= $hookmanager->resPrint;
1108 if (isModEnabled(
'api')) {
1111 print
'<tr><td>'.$langs->trans(
"ApiKey").
'</td>';
1113 print
'<input class="minwidth300 maxwidth400 widthcentpercentminusx" minlength="12" maxlength="128" type="text" id="api_key" name="api_key" value="'.GETPOST(
'api_key',
'alphanohtml').
'" autocomplete="off">';
1114 if (!empty($conf->use_javascript_ajax)) {
1115 print
img_picto($langs->trans(
'Generate'),
'refresh',
'id="generate_api_key" class="linkobject paddingleft"');
1121 print
'<input type="hidden" name="api_key" value="'.$generated_fake_api_key.
'">';
1125 print
'</table><hr><table class="border centpercent">';
1129 print
'<tr><td class="tdtop titlefieldcreate">'.$form->editfieldkey(
'Address',
'address',
'', $object, 0).
'</td>';
1130 print
'<td><textarea name="address" id="address" class="quatrevingtpercent" rows="3" wrap="soft">';
1131 print $object->address;
1132 print
'</textarea></td></tr>';
1135 print
'<tr><td>'.$form->editfieldkey(
'Zip',
'zipcode',
'', $object, 0).
'</td><td>';
1136 print $formcompany->select_ziptown($object->zip,
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6);
1140 print
'<tr><td>'.$form->editfieldkey(
'Town',
'town',
'', $object, 0).
'</td><td>';
1141 print $formcompany->select_ziptown($object->town,
'town', array(
'zipcode',
'selectcountry_id',
'state_id'));
1145 print
'<tr><td>'.$form->editfieldkey(
'Country',
'selectcountry_id',
'', $object, 0).
'</td><td class="maxwidthonsmartphone">';
1146 print
img_picto(
'',
'country',
'class="pictofixedwidth"');
1147 print $form->select_country((
GETPOST(
'country_id') !=
'' ?
GETPOST(
'country_id') : $object->country_id),
'country_id');
1149 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1155 print
'<tr><td>'.$form->editfieldkey(
'State',
'state_id',
'', $object, 0).
'</td><td class="maxwidthonsmartphone">';
1156 print
img_picto(
'',
'state',
'class="pictofixedwidth"');
1157 print $formcompany->select_state_ajax(
'country_id', $object->state_id, $object->country_id,
'state_id');
1162 print
'<tr><td>'.$langs->trans(
"PhonePro").
'</td>';
1164 print
img_picto(
'',
'object_phoning',
'class="pictofixedwidth"');
1165 if (!empty($ldap_phone)) {
1166 print
'<input type="hidden" name="office_phone" value="'.dol_escape_htmltag($ldap_phone).
'">';
1169 print
'<input class="maxwidth200 widthcentpercentminusx" type="text" name="office_phone" value="'.dol_escape_htmltag(
GETPOST(
'office_phone',
'alphanohtml')).
'">';
1174 print
'<tr><td>'.$langs->trans(
"PhoneMobile").
'</td>';
1176 print
img_picto(
'',
'object_phoning_mobile',
'class="pictofixedwidth"');
1177 if (!empty($ldap_mobile)) {
1178 print
'<input type="hidden" name="user_mobile" value="'.dol_escape_htmltag($ldap_mobile).
'">';
1181 print
'<input class="maxwidth200 widthcentpercentminusx" type="text" name="user_mobile" value="'.dol_escape_htmltag(
GETPOST(
'user_mobile',
'alphanohtml')).
'">';
1186 print
'<tr><td>'.$langs->trans(
"Fax").
'</td>';
1188 print
img_picto(
'',
'object_phoning_fax',
'class="pictofixedwidth"');
1189 if (!empty($ldap_fax)) {
1190 print
'<input type="hidden" name="office_fax" value="'.dol_escape_htmltag($ldap_fax).
'">';
1193 print
'<input class="maxwidth200 widthcentpercentminusx" type="text" name="office_fax" value="'.dol_escape_htmltag(
GETPOST(
'office_fax',
'alphanohtml')).
'">';
1198 print
'<tr><td'.(getDolGlobalString(
'USER_MAIL_REQUIRED') ?
' class="fieldrequired"' :
'').
'>'.$langs->trans(
"EMail").
'</td>';
1200 print
img_picto(
'',
'object_email',
'class="pictofixedwidth"');
1201 if (!empty($ldap_mail)) {
1202 print
'<input type="hidden" name="email" value="'.dol_escape_htmltag($ldap_mail).
'">';
1205 print
'<input type="text" name="email" class="maxwidth500 widthcentpercentminusx" value="'.dol_escape_htmltag(
GETPOST(
'email',
'alphanohtml')).
'">';
1210 if (isModEnabled(
'socialnetworks')) {
1211 foreach ($socialnetworks as $key => $value) {
1212 if ($value[
'active']) {
1213 print
'<tr><td>'.$langs->trans($value[
'label']).
'</td>';
1215 if (!empty($value[
'icon'])) {
1216 print
'<span class="fab '.$value[
'icon'].
' pictofixedwidth"></span>';
1218 if (!empty($ldap_social[$key])) {
1219 print
'<input type="hidden" name="'.$key.
'" value="'.$ldap_social[$key].
'">';
1220 print $ldap_social[$key];
1222 print
'<input class="maxwidth200 widthcentpercentminusx" type="text" name="'.$key.
'" value="'.
GETPOST($key,
'alphanohtml').
'">';
1227 if (!empty($ldap_social[$key])) {
1228 print
'<input type="hidden" name="'.$key.
'" value="'.$ldap_social[$key].
'">';
1230 print
'<input type="hidden" name="'.$key.
'" value="'.
GETPOST($key,
'alphanohtml').
'">';
1237 if (isModEnabled(
'accounting')) {
1238 print
'<tr><td>'.$langs->trans(
"AccountancyCode").
'</td>';
1240 print
'<input type="text" class="maxwidthonsmartphone" name="accountancy_code" value="'.dol_escape_htmltag(
GETPOST(
'accountancy_code',
'alphanohtml')).
'">';
1245 if (isModEnabled(
'agenda')) {
1246 print
'<tr><td>'.$langs->trans(
"ColorUser").
'</td>';
1248 print $formother->selectColor(GETPOSTISSET(
'color') ?
GETPOST(
'color',
'alphanohtml') : $object->color,
'color', null, 1,
'',
'hideifnotset');
1253 if (isModEnabled(
'categorie') && $user->hasRight(
"categorie",
"read")) {
1254 print
'<tr><td>'.$form->editfieldkey(
'Categories',
'usercats',
'', $object, 0).
'</td><td>';
1255 $cate_arbo = $form->select_all_categories(
'user',
null,
'parent',
null,
null, 1);
1256 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'usercats', $cate_arbo,
GETPOST(
'usercats',
'array'), 0, 0,
'maxwdith300 widthcentpercentminusx', 0,
'90%');
1262 print
'<tr><td>'.$form->editfieldkey(
'DefaultLang',
'default_lang',
'', $object, 0,
'string',
'', 0, 0,
'id', $langs->trans(
"WarningNotLangOfInterface", $langs->transnoentitiesnoconv(
"UserGUISetup"))).
'</td>';
1263 print
'<td class="maxwidthonsmartphone">'.
"\n";
1264 print
img_picto(
'',
'language',
'class="pictofixedwidth"').$formadmin->select_language(
GETPOST(
'default_lang',
'alpha') ?
GETPOST(
'default_lang',
'alpha') : ($object->lang ? $object->lang :
''),
'default_lang', 0, 0, 1, 0, 0,
'maxwidth300 widthcentpercentminusx');
1270 if (isModEnabled(
'multicompany') && is_object($mc)) {
1272 if (!method_exists($mc,
'formObjectOptions')) {
1273 if (!
getDolGlobalString(
'MULTICOMPANY_TRANSVERSE_MODE') && $conf->entity == 1 && $user->admin && !$user->entity) {
1274 print
"<tr>".
'<td>'.$langs->trans(
"Entity").
'</td>';
1275 print
"<td>".$mc->select_entities($conf->entity);
1276 print
"</td></tr>\n";
1278 print
'<input type="hidden" name="entity" value="'.$conf->entity.
'" />';
1284 $parameters = array();
1285 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
1288 print
'<tr><td class="tdtop">'.$langs->trans(
"Signature").
'</td>';
1289 print
'<td class="wordbreak">';
1290 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1292 $doleditor =
new DolEditor(
'signature',
GETPOST(
'signature',
'restricthtml'),
'', 138,
'dolibarr_notes',
'In',
true, $acceptlocallinktomedia, !
getDolGlobalString(
'FCKEDITOR_ENABLE_USERSIGN') ? 0 : 1, ROWS_4,
'90%');
1293 print $doleditor->Create(1);
1297 print
'<tr><td class="tdtop">';
1298 print $langs->trans(
"NotePublic");
1300 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1301 $doleditor =
new DolEditor(
'note_public', GETPOSTISSET(
'note_public') ?
GETPOST(
'note_public',
'restricthtml') :
'',
'', 100,
'dolibarr_notes',
'', false, true,
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PUBLIC'), ROWS_3,
'90%');
1302 $doleditor->Create();
1303 print
"</td></tr>\n";
1306 print
'<tr><td class="tdtop">';
1307 print $langs->trans(
"NotePrivate");
1309 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1310 $doleditor =
new DolEditor(
'note_private', GETPOSTISSET(
'note_private') ?
GETPOST(
'note_private',
'restricthtml') :
'',
'', 100,
'dolibarr_notes',
'', false, true,
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PRIVATE'), ROWS_3,
'90%');
1311 $doleditor->Create();
1312 print
"</td></tr>\n";
1314 print
'</table><hr><table class="border centpercent">';
1321 print
'<tr><td>'.$langs->trans(
"DefaultWarehouse").
'</td><td>';
1322 print $formproduct->selectWarehouses($object->fk_warehouse,
'fk_warehouse',
'warehouseopen', 1);
1327 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"PostOrFunction").
'</td>';
1329 print
'<input class="maxwidth200 maxwidth150onsmartphone" type="text" name="job" value="'.dol_escape_htmltag(
GETPOST(
'job',
'alphanohtml')).
'">';
1332 if ((isModEnabled(
'salaries') && $user->hasRight(
"salaries",
"read") && in_array($id, $childids))
1333 || (isModEnabled(
'salaries') && $user->hasRight(
"salaries",
"readall"))
1334 || (isModEnabled(
'hrm') && $user->hasRight(
"hrm",
"employee",
"read"))) {
1335 $langs->load(
"salaries");
1339 $text = $langs->trans(
"THM");
1340 print $form->textwithpicto($text, $langs->trans(
"THMDescription"), 1,
'help',
'classthm');
1343 print
'<input size="8" type="text" name="thm" value="'.dol_escape_htmltag(
GETPOST(
'thm')).
'"> '.$langs->getCurrencySymbol($conf->currency);
1349 $text = $langs->trans(
"TJM");
1350 print $form->textwithpicto($text, $langs->trans(
"TJMDescription"), 1,
'help',
'classtjm');
1353 print
'<input size="8" type="text" name="tjm" value="'.dol_escape_htmltag(
GETPOST(
'tjm')).
'"> '.$langs->getCurrencySymbol($conf->currency);
1358 print
'<tr><td>'.$langs->trans(
"Salary").
'</td>';
1360 print
img_picto(
'',
'salary',
'class="pictofixedwidth paddingright"').
'<input class="width100" type="text" name="salary" value="'.
dol_escape_htmltag(
GETPOST(
'salary')).
'"> '.$langs->getCurrencySymbol($conf->currency);
1366 print
'<tr><td>'.$langs->trans(
"WeeklyHours").
'</td>';
1368 print
'<input size="8" type="text" name="weeklyhours" value="'.dol_escape_htmltag(
GETPOST(
'weeklyhours')).
'">';
1373 print
'<tr><td>'.$langs->trans(
"DateOfEmployment").
'</td>';
1375 print $form->selectDate($dateemployment,
'dateemployment', 0, 0, 1,
'formdateemployment', 1, 1, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"from"));
1379 print $form->selectDate($dateemploymentend,
'dateemploymentend', 0, 0, 1,
'formdateemploymentend', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"));
1384 print
'<tr><td>'.$langs->trans(
"DateOfBirth").
'</td>';
1386 print $form->selectDate($dateofbirth,
'dateofbirth', 0, 0, 1,
'createuser', 1, 0, 0,
'', 0,
'',
'', 1,
'',
'',
'tzserver');
1394 print $form->buttonsSaveCancel(
"CreateUser");
1400 $res = $object->fetch($id,
'',
'', 1);
1405 $res = $object->fetch_optionals();
1409 $object->getrights();
1410 if (empty($object->nb_rights) && $object->statut != 0 && empty($object->admin)) {
1417 if (isModEnabled(
'ldap') && !empty($object->ldap_sid)) {
1419 $result = $ldap->connect_bind();
1421 $userSearchFilter =
'(' .
getDolGlobalString(
'LDAP_FILTER_CONNECTION').
'('.$ldap->getUserIdentifier().
'='.$object->login.
'))';
1422 $entries = $ldap->fetch($object->login, $userSearchFilter);
1427 $passDoNotExpire = 0;
1428 $userChangePassNextLogon = 0;
1433 if (count($ldap->uacf) > 0) {
1434 foreach ($ldap->uacf as $key => $statut) {
1435 if ($key == 65536) {
1436 $passDoNotExpire = 1;
1437 $statutUACF = $statut;
1442 $statutUACF =
"ACCOUNTDISABLE";
1445 if ($ldap->pwdlastset == 0) {
1446 $userChangePassNextLogon = 1;
1452 if ($mode ==
'employee') {
1453 $title = $langs->trans(
"Employee");
1454 $linkback =
'<a href="'.DOL_URL_ROOT.
'/hrm/employee/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
1456 $title = $langs->trans(
"User");
1459 if ($user->hasRight(
"user",
"user",
"read") || $user->admin) {
1460 $linkback =
'<a href="'.DOL_URL_ROOT.
'/user/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
1469 if ($action ==
'password') {
1470 print $form->formconfirm($_SERVER[
'PHP_SELF'].
"?id=$object->id", $langs->trans(
"ReinitPassword"), $langs->trans(
"ConfirmReinitPassword", $object->login),
"confirm_password",
'', 0, 1);
1476 if ($action ==
'passwordsend') {
1477 print $form->formconfirm($_SERVER[
'PHP_SELF'].
"?id=$object->id", $langs->trans(
"SendNewPassword"), $langs->trans(
"ConfirmSendNewPassword", $object->login),
"confirm_passwordsend",
'', 0, 1);
1483 if ($action ==
'disable') {
1484 print $form->formconfirm($_SERVER[
'PHP_SELF'].
"?id=$object->id", $langs->trans(
"DisableAUser"), $langs->trans(
"ConfirmDisableUser", $object->login),
"confirm_disable",
'', 0, 1);
1490 if ($action ==
'enable') {
1491 print $form->formconfirm($_SERVER[
'PHP_SELF'].
"?id=$object->id", $langs->trans(
"EnableAUser"), $langs->trans(
"ConfirmEnableUser", $object->login),
"confirm_enable",
'', 0, 1);
1497 if ($action ==
'delete') {
1498 print $form->formconfirm($_SERVER[
'PHP_SELF'].
"?id=$object->id", $langs->trans(
"DeleteAUser"), $langs->trans(
"ConfirmDeleteUser", $object->login),
"confirm_delete",
'', 0, 1);
1504 if ($action !=
'edit') {
1507 $morehtmlref =
'<a href="'.DOL_URL_ROOT.
'/user/vcard.php?id='.$object->id.
'&output=file&file='.urlencode(
dol_sanitizeFileName($object->getFullName($langs).
'.vcf')).
'" class="refid" rel="noopener" rel="noopener">';
1508 $morehtmlref .=
img_picto($langs->trans(
"Download").
' '.$langs->trans(
"VCard").
' ('.$langs->trans(
"AddToContacts").
')',
'vcard.png',
'class="valignmiddle marginleftonly paddingrightonly"');
1509 $morehtmlref .=
'</a>';
1511 $urltovirtualcard =
'/user/virtualcard.php?id='.((int) $object->id);
1512 $morehtmlref .=
dolButtonToOpenUrlInDialogPopup(
'publicvirtualcard', $langs->transnoentitiesnoconv(
"PublicVirtualCardUrl").
' - '.$object->getFullName($langs),
img_picto($langs->trans(
"PublicVirtualCardUrl"),
'card',
'class="valignmiddle marginleftonly paddingrightonly"'), $urltovirtualcard,
'',
'nohover');
1514 dol_banner_tab($object,
'id', $linkback, $user->hasRight(
"user",
"user",
"read") || $user->admin,
'rowid',
'ref', $morehtmlref);
1516 print
'<div class="fichecenter">';
1517 print
'<div class="fichehalfleft">';
1519 print
'<div class="underbanner clearboth"></div>';
1520 print
'<table class="border tableforfield centpercent">';
1523 print
'<tr><td class="titlefieldmiddle">'.$langs->trans(
"Login").
'</td>';
1524 if (!empty($object->ldap_sid) && $object->statut == 0) {
1525 print
'<td class="error">';
1526 print $langs->trans(
"LoginAccountDisableInDolibarr");
1531 if (property_exists($object,
'admin')) {
1532 if (isModEnabled(
'multicompany') && !empty($object->admin) && empty($object->entity)) {
1533 $addadmin .=
img_picto($langs->trans(
"SuperAdministratorDesc"),
"redstar",
'class="paddingleft"');
1534 } elseif (!empty($object->admin)) {
1535 $addadmin .=
img_picto($langs->trans(
"AdministratorDesc"),
"star",
'class="paddingleft"');
1545 $text = $langs->trans(
"Type");
1546 print $form->textwithpicto($text, $langs->trans(
"InternalExternalDesc"));
1548 $type = $langs->trans(
"Internal");
1549 if ($object->socid > 0) {
1550 $type = $langs->trans(
"External");
1552 print
'<span class="badgeneutral">';
1554 if ($object->ldap_sid) {
1555 print
' ('.$langs->trans(
"DomainUser").
')';
1558 print
'</td></tr>'.
"\n";
1561 if ($object->ldap_sid) {
1562 print
'<tr><td>'.$langs->trans(
"Type").
'</td><td>';
1563 print $langs->trans(
"DomainUser", $ldap->domainFQDN);
1564 print
'</td></tr>'.
"\n";
1568 print
'<tr><td>'.$langs->trans(
"Employee").
'</td><td>';
1569 print
'<input type="checkbox" disabled name="employee" value="1"'.($object->employee ?
' checked="checked"' :
'').
'>';
1571 print
'</td></tr>'.
"\n";
1576 print
'<tr><td>'.$langs->trans(
"HierarchicalResponsible").
'</td>';
1578 if (empty($object->fk_user)) {
1579 print
'<span class="opacitymedium">'.$langs->trans(
"None").
'</span>';
1581 $huser =
new User($db);
1582 if ($object->fk_user > 0) {
1583 $huser->fetch($object->fk_user);
1584 print $huser->getNomUrl(-1);
1586 print
'<span class="opacitymedium">'.$langs->trans(
"None").
'</span>';
1593 if (isModEnabled(
'expensereport')) {
1595 $text = $langs->trans(
"ForceUserExpenseValidator");
1596 print $form->textwithpicto($text, $langs->trans(
"ValidatorIsSupervisorByDefault"), 1,
'help');
1599 if (!empty($object->fk_user_expense_validator)) {
1600 $evuser =
new User($db);
1601 $evuser->fetch($object->fk_user_expense_validator);
1602 print $evuser->getNomUrl(-1);
1609 if (isModEnabled(
'holiday')) {
1611 $text = $langs->trans(
"ForceUserHolidayValidator");
1612 print $form->textwithpicto($text, $langs->trans(
"ValidatorIsSupervisorByDefault"), 1,
'help');
1615 if (!empty($object->fk_user_holiday_validator)) {
1616 $hvuser =
new User($db);
1617 $hvuser->fetch($object->fk_user_holiday_validator);
1618 print $hvuser->getNomUrl(-1);
1625 print
'<tr><td>'.$langs->trans(
"PostOrFunction").
'</td>';
1626 print
'<td>'.dol_escape_htmltag($object->job).
'</td>';
1630 print
'<tr><td>'.$langs->trans(
"WeeklyHours").
'</td>';
1637 if ((empty($user->socid) && in_array($id, $childids))
1638 || (isModEnabled(
'salaries') && $user->hasRight(
"salaries",
"readall"))
1639 || (isModEnabled(
'hrm') && $user->hasRight(
"hrm",
"employee",
"read"))) {
1640 $langs->load(
"salaries");
1643 print
'<tr><td>'.$langs->trans(
"Salary").
'</td>';
1645 print($object->salary !=
'' ?
img_picto(
'',
'salary',
'class="pictofixedwidth paddingright"').
'<span class="amount">'.
price($object->salary,
'', $langs, 1, -1, -1, $conf->currency) :
'').
'</span>';
1651 $text = $langs->trans(
"THM");
1652 print $form->textwithpicto($text, $langs->trans(
"THMDescription"), 1,
'help',
'classthm');
1655 print($object->thm !=
'' ?
price($object->thm,
'', $langs, 1, -1, -1, $conf->currency) :
'');
1661 $text = $langs->trans(
"TJM");
1662 print $form->textwithpicto($text, $langs->trans(
"TJMDescription"), 1,
'help',
'classtjm');
1665 print($object->tjm !=
'' ?
price($object->tjm,
'', $langs, 1, -1, -1, $conf->currency) :
'');
1671 print
'<tr><td>'.$langs->trans(
"DateOfEmployment").
'</td>';
1673 if ($object->dateemployment) {
1674 print
'<span class="opacitymedium">'.$langs->trans(
"FromDate").
'</span> ';
1677 if ($object->dateemploymentend) {
1678 print
'<span class="opacitymedium"> - '.$langs->trans(
"To").
'</span> ';
1685 print
'<tr><td>'.$langs->trans(
"DateOfBirth").
'</td>';
1693 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/entrepot.class.php';
1694 print
'<tr><td>'.$langs->trans(
"DefaultWarehouse").
'</td><td>';
1695 if ($object->fk_warehouse > 0) {
1696 $warehousestatic =
new Entrepot($db);
1697 $warehousestatic->fetch($object->fk_warehouse);
1698 print $warehousestatic->getNomUrl(1);
1706 print
'<div class="fichehalfright">';
1708 print
'<div class="underbanner clearboth"></div>';
1710 print
'<table class="border tableforfield centpercent">';
1713 if (isModEnabled(
'agenda')) {
1714 print
'<tr><td class="titlefield">'.$langs->trans(
"ColorUser").
'</td>';
1716 print $formother->showColor($object->color,
'');
1722 if (isModEnabled(
'categorie') && $user->hasRight(
"categorie",
"read")) {
1723 print
'<tr><td class="titlefield">'.$langs->trans(
"Categories").
'</td>';
1724 print
'<td colspan="3">';
1725 print $form->showCategories($object->id, Categorie::TYPE_USER, 1);
1731 $langs->load(
"languages");
1732 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
1733 print
'<tr><td class="titlefield">';
1734 print $form->textwithpicto($langs->trans(
"DefaultLang"), $langs->trans(
"WarningNotLangOfInterface", $langs->transnoentitiesnoconv(
"UserGUISetup")));
1738 $labellang = ($object->lang ? $langs->trans(
'Language_'.$object->lang) :
'');
1739 print
picto_from_langcode($object->lang,
'class="paddingrightonly saturatemedium opacitylow"');
1744 if (isset($conf->file->main_authentication) && preg_match(
'/openid/', $conf->file->main_authentication) &&
getDolGlobalString(
'MAIN_OPENIDURL_PERUSER')) {
1745 print
'<tr><td>'.$langs->trans(
"OpenIDURL").
'</td>';
1746 print
'<td>'.$object->openid.
'</td>';
1751 if (isModEnabled(
'multicompany') && is_object($mc)) {
1753 if (!method_exists($mc,
'formObjectOptions')) {
1754 if (isModEnabled(
'multicompany') && !
getDolGlobalString(
'MULTICOMPANY_TRANSVERSE_MODE') && $conf->entity == 1 && $user->admin && !$user->entity) {
1755 print
'<tr><td>'.$langs->trans(
"Entity").
'</td><td>';
1756 if (empty($object->entity)) {
1757 print $langs->trans(
"AllEntities");
1759 $mc->getInfo($object->entity);
1762 print
"</td></tr>\n";
1768 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
1771 if (isModEnabled(
"societe")) {
1772 print
'<tr><td>'.$langs->trans(
"LinkToCompanyContact").
'</td>';
1775 if (isset($object->socid) && $object->socid > 0) {
1777 $societe->fetch($object->socid);
1778 if ($societe->id > 0) {
1779 $s .= $societe->getNomUrl(1,
'');
1782 $s .=
'<span class="opacitymedium hideonsmartphone">'.$langs->trans(
"ThisUserIsNot").
'</span>';
1784 if (!empty($object->contact_id)) {
1786 $contact->fetch($object->contact_id);
1787 if ($contact->id > 0) {
1788 if ($object->socid > 0 && $s) {
1793 $s .= $contact->getNomUrl(1,
'');
1802 if (isModEnabled(
'adherent')) {
1803 $langs->load(
"members");
1804 print
'<tr><td>'.$langs->trans(
"LinkedToDolibarrMember").
'</td>';
1806 if ($object->fk_member) {
1808 $adh->fetch($object->fk_member);
1809 $adh->ref = $adh->getFullname($langs);
1810 print $adh->getNomUrl(-1);
1812 print
'<span class="opacitymedium hideonsmartphone">'.$langs->trans(
"UserNotLinkedToMember").
'</span>';
1819 print
'<tr><td class="tdtop">'.$langs->trans(
'Signature').
'</td><td class="wordbreak">';
1821 print
"</td></tr>\n";
1829 print
'<div class="div-table-responsive-no-min">';
1830 print
'<table class="border tableforfield centpercent">';
1832 print
'<tr class="liste_titre"><td class="liste_titre">';
1833 print
img_picto(
'',
'security',
'class="paddingleft pictofixedwidth"').$langs->trans(
"Credentials");
1835 print
'<td class="liste_titre"></td>';
1839 print
'<tr class="nooddeven"><td class="titlefield">'.$langs->trans(
"RangeOfLoginValidity").
'</td>';
1841 if ($object->datestartvalidity) {
1842 print
'<span class="opacitymedium">'.$langs->trans(
"FromDate").
'</span> ';
1845 if ($object->dateendvalidity) {
1846 print
'<span class="opacitymedium"> - '.$langs->trans(
"To").
'</span> ';
1853 if (!empty($object->email_oauth2) && preg_match(
'/googleoauth/', $dolibarr_main_authentication)) {
1854 print
'<tr class="nooddeven"><td class="titlefield">'.$langs->trans(
"AlternativeEmailForOAuth2").
'</td>';
1863 if (preg_match(
'/ldap/', $dolibarr_main_authentication)) {
1864 if (!empty($object->ldap_sid)) {
1865 if ($passDoNotExpire) {
1866 $valuetoshow .= ($valuetoshow ? (
' '.$langs->trans(
"or").
' ') :
'').$langs->trans(
"LdapUacf_".$statutUACF);
1867 } elseif ($userChangePassNextLogon) {
1868 $valuetoshow .= ($valuetoshow ? (
' '.$langs->trans(
"or").
' ') :
'').
'<span class="warning">'.$langs->trans(
"UserMustChangePassNextLogon", $ldap->domainFQDN).
'</span>';
1869 } elseif ($userDisabled) {
1870 $valuetoshow .= ($valuetoshow ? (
' '.$langs->trans(
"or").
' ') :
'').
'<span class="warning">'.$langs->trans(
"LdapUacf_".$statutUACF, $ldap->domainFQDN).
'</span>';
1872 $valuetoshow .= ($valuetoshow ? (
' '.$langs->trans(
"or").
' ') :
'').$langs->trans(
"PasswordOfUserInLDAP");
1875 $valuetoshow .= ($valuetoshow ? (
' '.$langs->trans(
"or").
' ') :
'').$langs->trans(
"PasswordOfUserInLDAP");
1878 if (preg_match(
'/http/', $dolibarr_main_authentication)) {
1879 $valuetoshow .= ($valuetoshow ? (
' '.$langs->trans(
"or").
' ') :
'').$langs->trans(
"HTTPBasicPassword");
1900 $parameters = array(
'valuetoshow' => $valuetoshow);
1901 $reshook = $hookmanager->executeHooks(
'printUserPasswordField', $parameters, $object, $action);
1903 $valuetoshow = $hookmanager->resPrint;
1905 $valuetoshow .= $hookmanager->resPrint;
1909 print
'<tr class="nooddeven"><td class="titlefield">'.$langs->trans(
"Password").
'</td>';
1910 print
'<td class="wordbreak">';
1917 if (isModEnabled(
'api') && ($user->id == $id || $user->admin || $user->hasRight(
"api",
"apikey",
"generate"))) {
1918 print
'<tr class="nooddeven"><td>'.$langs->trans(
"ApiKey").
'</td>';
1920 if (!empty($object->api_key)) {
1921 print
'<span class="opacitymedium">';
1928 print
'<tr class="nooddeven"><td>'.$langs->trans(
"LastConnexion").
'</td>';
1930 if ($object->datepreviouslogin) {
1931 print
dol_print_date($object->datepreviouslogin,
"dayhour",
"tzuserrel").
' <span class="opacitymedium">('.$langs->trans(
"Previous").
')</span>, ';
1933 if ($object->datelastlogin) {
1934 print
dol_print_date($object->datelastlogin,
"dayhour",
"tzuserrel").
' <span class="opacitymedium">('.$langs->trans(
"Currently").
')</span>';
1945 print
'<div class="clearboth"></div>';
1954 print
'<div class="tabsAction">';
1956 $parameters = array();
1957 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
1958 if (empty($reshook)) {
1962 'class' =>
'classfortooltip'
1966 if (empty($user->socid)) {
1967 $canSendMail =
false;
1968 if (!empty($object->email)) {
1969 $langs->load(
"mails");
1970 $canSendMail =
true;
1971 unset($params[
'attr'][
'title']);
1973 $langs->load(
"mails");
1974 $params[
'attr'][
'title'] = $langs->trans(
'NoEMail');
1976 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'default', $_SERVER[
'PHP_SELF'] .
'?id=' . $object->id .
'&action=presend&mode=init#formmailbeforetitle',
'', $canSendMail, $params);
1979 if ($caneditfield && (!isModEnabled(
'multicompany') || !$user->entity || ($object->entity == $conf->entity) || (
getDolGlobalString(
'MULTICOMPANY_TRANSVERSE_MODE') && $object->entity == 1))) {
1981 $params[
'attr'][
'title'] = $langs->trans(
'DisabledInMonoUserMode');
1982 print
dolGetButtonAction($langs->trans(
'Modify'),
'',
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false, $params);
1984 unset($params[
'attr'][
'title']);
1985 print
dolGetButtonAction($langs->trans(
'Modify'),
'',
'default', $_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=edit&token='.newToken(),
'',
true, $params);
1987 } elseif ($caneditpasswordandsee && !$object->ldap_sid &&
1988 (!isModEnabled(
'multicompany') || !$user->entity || ($object->entity == $conf->entity) || (
getDolGlobalString(
'MULTICOMPANY_TRANSVERSE_MODE') && $object->entity == 1))) {
1989 unset($params[
'attr'][
'title']);
1990 print
dolGetButtonAction($langs->trans(
'Modify'),
'',
'default', $_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=edit',
'',
true, $params);
1997 'class' =>
'classfortooltip'
2001 if ($object->status == $object::STATUS_DISABLED) {
2002 $params[
'attr'][
'title'] = $langs->trans(
'UserDisabled');
2003 print
dolGetButtonAction($langs->trans(
'ReinitPassword'),
'',
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false, $params);
2004 } elseif (($user->id != $id && $caneditpasswordandsee) && $object->login && !$object->ldap_sid &&
2005 ((!isModEnabled(
'multicompany') && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || (
getDolGlobalString(
'MULTICOMPANY_TRANSVERSE_MODE') && $object->entity == 1))) {
2006 unset($params[
'attr'][
'title']);
2007 print
dolGetButtonAction($langs->trans(
'ReinitPassword'),
'',
'default', $_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=password&token='.newToken(),
'',
true, $params);
2010 if ($object->status == $object::STATUS_DISABLED) {
2011 $params[
'attr'][
'title'] = $langs->trans(
'UserDisabled');
2012 print
dolGetButtonAction($langs->trans(
'SendNewPassword'),
'',
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false, $params);
2013 } elseif (($user->id != $id && $caneditpasswordandsend) && $object->login && !$object->ldap_sid &&
2014 ((!isModEnabled(
'multicompany') && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || (
getDolGlobalString(
'MULTICOMPANY_TRANSVERSE_MODE') && $object->entity == 1))) {
2015 if ($object->email) {
2016 unset($params[
'attr'][
'title']);
2017 print
dolGetButtonAction($langs->trans(
'SendNewPassword'),
'',
'default', $_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=passwordsend&token='.newToken(),
'',
true, $params);
2019 $params[
'attr'][
'title'] = $langs->trans(
'NoEMail');
2020 print
dolGetButtonAction($langs->trans(
'SendNewPassword'),
'',
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false, $params);
2025 if ($user->id != $id && $candisableuser && $object->statut == 0 &&
2026 ((!isModEnabled(
'multicompany') && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || (
getDolGlobalString(
'MULTICOMPANY_TRANSVERSE_MODE') && $object->entity == 1))) {
2027 unset($params[
'attr'][
'title']);
2028 print
dolGetButtonAction($langs->trans(
'Reactivate'),
'',
'default', $_SERVER[
'PHP_SELF'] .
'?id=' . $object->id .
'&action=enable&token='.newToken(),
'',
true, $params);
2031 if ($user->id != $id && $candisableuser && $object->statut == 1 &&
2032 ((!isModEnabled(
'multicompany') && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || (
getDolGlobalString(
'MULTICOMPANY_TRANSVERSE_MODE') && $object->entity == 1))) {
2033 unset($params[
'attr'][
'title']);
2034 print
dolGetButtonAction($langs->trans(
'DisableUser'),
'',
'default', $_SERVER[
'PHP_SELF'] .
'?id=' . $object->id .
'&action=disable&token='.newToken(),
'',
true, $params);
2036 if ($user->id == $id) {
2037 $params[
'attr'][
'title'] = $langs->trans(
'CantDisableYourself');
2038 print
dolGetButtonAction($langs->trans(
'DisableUser'),
'',
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false, $params);
2042 if ($user->id != $id && $candisableuser &&
2043 ((!isModEnabled(
'multicompany') && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || (
getDolGlobalString(
'MULTICOMPANY_TRANSVERSE_MODE') && $object->entity == 1))) {
2044 if ($user->admin || !$object->admin) {
2045 unset($params[
'attr'][
'title']);
2046 print
dolGetButtonAction($langs->trans(
'DeleteUser'),
'',
'default', $_SERVER[
'PHP_SELF'].
'?action=delete&token='.newToken().
'&id='.$object->id,
'',
true, $params);
2048 $params[
'attr'][
'title'] = $langs->trans(
'MustBeAdminToDeleteOtherAdmin');
2049 print
dolGetButtonAction($langs->trans(
'DeleteUser'),
'',
'default', $_SERVER[
'PHP_SELF'].
'?action=delete&token='.newToken().
'&id='.$object->id,
'',
false, $params);
2059 if (
GETPOST(
'modelselected')) {
2060 $action =
'presend';
2064 $modelmail =
'user';
2065 $defaulttopic =
'Information';
2066 $diroutput = $conf->user->dir_output;
2067 $trackid =
'use'.$object->id;
2069 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
2071 if ($action !=
'presend' && $action !=
'send') {
2076 if ($canreadgroup) {
2077 print
'<!-- Group section -->'.
"\n";
2085 $groupslist = $usergroup->listGroupsForUser($object->id,
false);
2087 if (!empty($groupslist)) {
2088 foreach ($groupslist as $groupforuser) {
2089 $exclude[] = $groupforuser->id;
2094 $parameters = array(
'caneditgroup' => $caneditgroup,
'groupslist' => $groupslist,
'exclude' => $exclude);
2095 $reshook = $hookmanager->executeHooks(
'formAddUserToGroup', $parameters, $object, $action);
2096 print $hookmanager->resPrint;
2098 if (empty($reshook)) {
2099 if ($caneditgroup) {
2100 print
'<form action="'.$_SERVER[
'PHP_SELF'].
'?id='.$id.
'" method="POST">'.
"\n";
2101 print
'<input type="hidden" name="token" value="'.newToken().
'" />';
2102 print
'<input type="hidden" name="action" value="addgroup" />';
2103 print
'<input type="hidden" name="page_y" value="" />';
2106 print
'<!-- List of groups of the user -->'.
"\n";
2107 print
'<table class="noborder centpercent">'.
"\n";
2108 print
'<tr class="liste_titre"><th class="liste_titre">'.$langs->trans(
"Groups").
'</th>'.
"\n";
2109 print
'<th class="liste_titre right">';
2110 if ($caneditgroup) {
2111 print $form->select_dolgroups(
'',
'group', 1, $exclude, 0,
'',
'', $object->entity,
false,
'maxwidth150');
2113 print
'<input type="hidden" name="entity" value="'.$conf->entity.
'" />';
2114 print
'<input type="submit" class="button buttongen button-add reposition" value="'.$langs->trans(
"Add").
'" />';
2116 print
'</th></tr>'.
"\n";
2119 if (!empty($groupslist)) {
2120 foreach ($groupslist as $group) {
2121 print
'<tr class="oddeven">';
2122 print
'<td class="tdoverflowmax150">';
2123 if ($caneditgroup) {
2124 print $group->getNomUrl(1);
2126 print
img_object($langs->trans(
"ShowGroup"),
"group").
' '.$group->name;
2129 print
'<td class="right">';
2130 if ($caneditgroup) {
2131 print
'<a class="reposition" href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=removegroup&token='.newToken().
'&group='.((int) $group->id).
'">';
2132 print
img_picto($langs->trans(
"RemoveFromGroup"),
'unlink');
2137 print
"</td></tr>\n";
2140 print
'<tr class="oddeven"><td colspan="3"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
2145 if ($caneditgroup) {
2157 if ($action ==
'edit' && ($canedituser || $caneditpasswordandsee)) {
2158 print
'<form action="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'" method="POST" name="updateuser" enctype="multipart/form-data">';
2159 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2160 print
'<input type="hidden" name="action" value="update">';
2161 print
'<input type="hidden" name="entity" value="'.$object->entity.
'">';
2165 print
'<table class="border centpercent">';
2169 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Ref").
'</td>';
2177 print
'<tr><td class="titlefieldcreate"><label for="civility_code">'.$langs->trans(
"UserTitle").
'</label></td><td>';
2178 if ($caneditfield && !$object->ldap_sid) {
2179 print $formcompany->select_civility(GETPOSTISSET(
"civility_code") ?
GETPOST(
"civility_code",
'aZ09') : $object->civility_code,
'civility_code');
2180 } elseif ($object->civility_code) {
2181 print $langs->trans(
"Civility".$object->civility_code);
2187 print
'<td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Lastname").
'</td>';
2189 if ($caneditfield && !$object->ldap_sid) {
2190 print
'<input class="minwidth100" type="text" class="flat" name="lastname" value="'.$object->lastname.
'">';
2192 print
'<input type="hidden" name="lastname" value="'.$object->lastname.
'">';
2193 print $object->lastname;
2199 print
'<tr><td>'.$langs->trans(
"Firstname").
'</td>';
2201 if ($caneditfield && !$object->ldap_sid) {
2202 print
'<input class="minwidth100" type="text" class="flat" name="firstname" value="'.$object->firstname.
'">';
2204 print
'<input type="hidden" name="firstname" value="'.$object->firstname.
'">';
2205 print $object->firstname;
2210 print
"<tr>".
'<td><span class="fieldrequired">'.$langs->trans(
"Login").
'</span></td>';
2212 if ($user->admin && !$object->ldap_sid) {
2213 print
'<input maxlength="50" type="text" class="flat" name="login" value="'.$object->login.
'">';
2215 print
'<input type="hidden" name="login" value="'.$object->login.
'">';
2216 print $object->login;
2222 print
'<tr><td>'.$form->textwithpicto($langs->trans(
"Administrator"), $langs->trans(
"AdministratorDesc")).
'</td>';
2223 if ($object->socid > 0) {
2224 $langs->load(
"admin");
2226 print
'<input type="hidden" name="admin" value="'.$object->admin.
'">'.
yn($object->admin);
2227 print
' <span class="opacitymedium">('.$langs->trans(
"ExternalUser").
')</span>';
2231 $nbAdmin = $user->getNbOfUsers(
'active',
'', 1);
2232 $nbSuperAdmin = $user->getNbOfUsers(
'active',
'superadmin', 1);
2236 && ($user->id != $object->id)
2238 (!isModEnabled(
'multicompany') && $nbAdmin >= 1)
2239 || (isModEnabled(
'multicompany') && (($object->entity > 0 || ($user->entity == 0 && $object->entity == 0)) || $nbSuperAdmin > 1))
2242 print $form->selectyesno(
'admin', $object->admin, 1,
false, 0, 1);
2244 if (isModEnabled(
'multicompany') && !$user->entity) {
2245 if ($conf->use_javascript_ajax) {
2246 print
'<script type="text/javascript">
2248 var admin = $("select[name=admin]").val();
2250 $("input[name=superadmin]")
2251 .prop("disabled", true)
2252 .prop("checked", false);
2254 if ($("input[name=superadmin]").is(":checked")) {
2255 $("select[name=entity]")
2256 .prop("disabled", true);
2258 $("select[name=admin]").change(function() {
2259 if ( $(this).val() == 0 ) {
2260 $("input[name=superadmin]")
2261 .prop("disabled", true)
2262 .prop("checked", false);
2263 $("select[name=entity]")
2264 .prop("disabled", false);
2266 $("input[name=superadmin]")
2267 .prop("disabled", false);
2270 $("input[name=superadmin]").change(function() {
2271 if ( $(this).is(":checked")) {
2272 $("select[name=entity]")
2273 .prop("disabled", true);
2275 $("select[name=entity]")
2276 .prop("disabled", false);
2283 $checked = (($object->admin && !$object->entity) ?
' checked' :
'');
2284 print
'<input type="checkbox" name="superadmin" id="superadmin" value="1"'.$checked.
' /> <label for="superadmin">'.$langs->trans(
"SuperAdministrator").
'</span>';
2287 $yn =
yn($object->admin);
2288 print
'<input type="hidden" name="admin" value="'.$object->admin.
'">';
2289 print
'<input type="hidden" name="superadmin" value="'.(empty($object->entity) ? 1 : 0).
'">';
2290 if (isModEnabled(
'multicompany') && empty($object->entity)) {
2291 print $form->textwithpicto($yn, $langs->trans(
"DontDowngradeSuperAdmin"), 1,
'warning');
2300 print
'<tr><td>'.$langs->trans(
"Gender").
'</td>';
2302 $arraygender = array(
'man'=>$langs->trans(
"Genderman"),
'woman'=>$langs->trans(
"Genderwoman"),
'other'=>$langs->trans(
"Genderother"));
2303 if ($caneditfield) {
2304 print $form->selectarray(
'gender', $arraygender, GETPOSTISSET(
'gender') ?
GETPOST(
'gender') : $object->gender, 1);
2306 print $arraygender[$object->gender];
2312 print
'<td>'.$form->editfieldkey(
'Employee',
'employee',
'', $object, 0).
'</td><td>';
2313 if ($caneditfield) {
2314 print
'<input type="checkbox" name="employee" value="1"'.($object->employee ?
' checked="checked"' :
'').
'>';
2317 print
'<input type="checkbox" name="employee" disabled value="1"'.($object->employee ?
' checked="checked"' :
'').
'>';
2327 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"HierarchicalResponsible").
'</td>';
2329 if ($caneditfield) {
2330 print
img_picto(
'',
'user',
'class="pictofixedwidth"').$form->select_dolusers($object->fk_user,
'fk_user', 1, array($object->id), 0,
'', 0, $object->entity, 0, 0,
'', 0,
'',
'widthcentpercentminusx maxwidth300');
2332 print
'<input type="hidden" name="fk_user" value="'.$object->fk_user.
'">';
2333 $huser =
new User($db);
2334 $huser->fetch($object->fk_user);
2335 print $huser->getNomUrl(-1);
2341 if (isModEnabled(
'expensereport')) {
2342 print
'<tr><td class="titlefieldcreate">';
2343 $text = $langs->trans(
"ForceUserExpenseValidator");
2344 print $form->textwithpicto($text, $langs->trans(
"ValidatorIsSupervisorByDefault"), 1,
'help');
2347 if ($caneditfield) {
2348 print
img_picto(
'',
'user',
'class="pictofixedwidth"').$form->select_dolusers($object->fk_user_expense_validator,
'fk_user_expense_validator', 1, array($object->id), 0,
'', 0, $object->entity, 0, 0,
'', 0,
'',
'widthcentpercentminusx maxwidth300');
2350 print
'<input type="hidden" name="fk_user_expense_validator" value="'.$object->fk_user_expense_validator.
'">';
2351 $evuser =
new User($db);
2352 $evuser->fetch($object->fk_user_expense_validator);
2353 print $evuser->getNomUrl(-1);
2360 if (isModEnabled(
'holiday')) {
2361 print
'<tr><td class="titlefieldcreate">';
2362 $text = $langs->trans(
"ForceUserHolidayValidator");
2363 print $form->textwithpicto($text, $langs->trans(
"ValidatorIsSupervisorByDefault"), 1,
'help');
2366 if ($caneditfield) {
2367 print
img_picto(
'',
'user',
'class="pictofixedwidth"').$form->select_dolusers($object->fk_user_holiday_validator,
'fk_user_holiday_validator', 1, array($object->id), 0,
'', 0, $object->entity, 0, 0,
'', 0,
'',
'widthcentpercentminusx maxwidth300');
2369 print
'<input type="hidden" name="fk_user_holiday_validator" value="'.$object->fk_user_holiday_validator.
'">';
2370 $hvuser =
new User($db);
2371 $hvuser->fetch($object->fk_user_holiday_validator);
2372 print $hvuser->getNomUrl(-1);
2379 print
'<tr><td>'.$langs->trans(
"ExternalUser").
' ?</td>';
2381 if ($user->id == $object->id || !$user->admin) {
2383 $type = $langs->trans(
"Internal");
2384 if ($object->socid) {
2385 $type = $langs->trans(
"External");
2387 print $form->textwithpicto($type, $langs->trans(
"InternalExternalDesc"));
2388 if ($object->ldap_sid) {
2389 print
' ('.$langs->trans(
"DomainUser").
')';
2394 if ($object->contact_id) {
2395 $type = $object->contact_id;
2398 if ($object->socid > 0 && !($object->contact_id > 0)) {
2399 print
img_picto(
'',
'company').$form->select_company($object->socid,
'socid',
'',
' ', 0, 0,
null, 0,
'maxwidth300');
2400 print
img_picto(
'',
'contact').$form->selectcontacts(0, 0,
'contactid', 1,
'',
'', 1,
'maxwidth300',
false, 1);
2401 if ($object->ldap_sid) {
2402 print
' ('.$langs->trans(
"DomainUser").
')';
2404 } elseif ($object->socid > 0 && $object->contact_id > 0) {
2405 print
img_picto(
'',
'company').$form->select_company($object->socid,
'socid',
'',
' ', 0, 0,
null, 0,
'maxwidth300');
2406 print
img_picto(
'',
'contact').$form->selectcontacts(0, $object->contact_id,
'contactid', 1,
'',
'', 1,
'maxwidth300',
false, 1);
2407 if ($object->ldap_sid) {
2408 print
' ('.$langs->trans(
"DomainUser").
')';
2410 } elseif (!($object->socid > 0) && $object->contact_id > 0) {
2411 print
img_picto(
'',
'company').$form->select_company(0,
'socid',
'',
' ', 0, 0,
null, 0,
'maxwidth300');
2412 print
img_picto(
'',
'contact').$form->selectcontacts(0, $object->contact_id,
'contactid', 1,
'',
'', 1,
'maxwidth300',
false, 1);
2413 if ($object->ldap_sid) {
2414 print
' ('.$langs->trans(
"DomainUser").
')';
2417 print
img_picto(
'',
'company').$form->select_company(0,
'socid',
'',
' ', 0, 0,
null, 0,
'maxwidth300');
2418 print
img_picto(
'',
'contact').$form->selectcontacts(0, 0,
'contactid', 1,
'',
'', 1,
'maxwidth300',
false, 1);
2428 print
'<table class="border centpercent">';
2431 print
'<tr><td>'.$langs->trans(
"RangeOfLoginValidity").
'</td>';
2433 if ($caneditfield) {
2434 print $form->selectDate($datestartvalidity ? $datestartvalidity : $object->datestartvalidity,
'datestartvalidity', 0, 0, 1,
'formdatestartvalidity', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"from"));
2440 if ($caneditfield) {
2441 print $form->selectDate($dateendvalidity ? $dateendvalidity : $object->dateendvalidity,
'dateendvalidity', 0, 0, 1,
'formdateendvalidity', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"));
2449 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Password").
'</td>';
2452 if (preg_match(
'/ldap/', $dolibarr_main_authentication)) {
2453 $valuetoshow .= ($valuetoshow ? (
' '.$langs->trans(
"or").
' ') :
'').$langs->trans(
"PasswordOfUserInLDAP");
2455 if (preg_match(
'/http/', $dolibarr_main_authentication)) {
2456 $valuetoshow .= ($valuetoshow ? (
' '.$langs->trans(
"or").
' ') :
'').$form->textwithpicto($text, $langs->trans(
"DolibarrInHttpAuthenticationSoPasswordUseless", $dolibarr_main_authentication), 1,
'warning');
2458 if (preg_match(
'/dolibarr/', $dolibarr_main_authentication) || preg_match(
'/forceuser/', $dolibarr_main_authentication)) {
2459 if ($caneditpasswordandsee) {
2460 $valuetoshow .= ($valuetoshow ? (
' '.$langs->trans(
"or").
' ') :
'').
'<input maxlength="128" type="password" class="flat" id="password" name="password" value="'.
dol_escape_htmltag($object->pass).
'" autocomplete="new-password">';
2461 if (!empty($conf->use_javascript_ajax)) {
2462 $valuetoshow .=
img_picto((
getDolGlobalString(
'USER_PASSWORD_GENERATED') ===
'none' ? $langs->trans(
'NoPasswordGenerationRuleConfigured') : $langs->trans(
'Generate')),
'refresh',
'id="generate_password" class="paddingleft'.(
getDolGlobalString(
'USER_PASSWORD_GENERATED') ===
'none' ?
' opacitymedium' :
' linkobject').
'"');
2465 $valuetoshow .= ($valuetoshow ? (
' '.$langs->trans(
"or").
' ') :
'').preg_replace(
'/./i',
'*', $object->pass);
2469 $parameters = array(
'valuetoshow' => $valuetoshow,
'caneditpasswordandsee' => $caneditpasswordandsee,
'caneditpasswordandsend' => $caneditpasswordandsend);
2470 $reshook = $hookmanager->executeHooks(
'printUserPasswordField', $parameters, $object, $action);
2472 $valuetoshow = $hookmanager->resPrint;
2474 $valuetoshow .= $hookmanager->resPrint;
2478 print
"</td></tr>\n";
2481 if (isModEnabled(
'api')) {
2482 print
'<tr><td>'.$langs->trans(
"ApiKey").
'</td>';
2484 if ($caneditpasswordandsee || $user->hasRight(
"api",
"apikey",
"generate")) {
2485 print
'<input class="minwidth300 maxwidth400 widthcentpercentminusx" minlength="12" maxlength="128" type="text" id="api_key" name="api_key" value="'.$object->api_key.
'" autocomplete="off">';
2486 if (!empty($conf->use_javascript_ajax)) {
2487 print
img_picto($langs->trans(
'Generate'),
'refresh',
'id="generate_api_key" class="linkobject paddingleft"');
2494 if (isset($conf->file->main_authentication) && preg_match(
'/openid/', $conf->file->main_authentication) &&
getDolGlobalString(
'MAIN_OPENIDURL_PERUSER')) {
2495 print
"<tr>".
'<td>'.$langs->trans(
"OpenIDURL").
'</td>';
2497 if ($caneditfield) {
2498 print
'<input class="minwidth100" type="url" name="openid" class="flat" value="'.$object->openid.
'">';
2500 print
'<input type="hidden" name="openid" value="'.$object->openid.
'">';
2501 print $object->openid;
2506 print
'</table><hr><table class="border centpercent">';
2510 print
'<tr><td class="tdtop titlefieldcreate">'.$form->editfieldkey(
'Address',
'address',
'', $object, 0).
'</td>';
2512 if ($caneditfield) {
2513 print
'<textarea name="address" id="address" class="quatrevingtpercent" rows="3" wrap="soft">';
2516 if ($caneditfield) {
2517 print
'</textarea>';
2522 print
'<tr><td>'.$form->editfieldkey(
'Zip',
'zipcode',
'', $object, 0).
'</td><td>';
2523 if ($caneditfield) {
2524 print $formcompany->select_ziptown((GETPOSTISSET(
'zipcode') ?
GETPOST(
'zipcode') : $object->zip),
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6);
2531 print
'<tr><td>'.$form->editfieldkey(
'Town',
'town',
'', $object, 0).
'</td><td>';
2532 if ($caneditfield) {
2533 print $formcompany->select_ziptown((GETPOSTISSET(
'town') ?
GETPOST(
'town') : $object->town),
'town', array(
'zipcode',
'selectcountry_id',
'state_id'));
2535 print $object->town;
2540 print
'<tr><td>'.$form->editfieldkey(
'Country',
'selectcounty_id',
'', $object, 0).
'</td><td>';
2541 print
img_picto(
'',
'country',
'class="pictofixedwidth"');
2542 if ($caneditfield) {
2543 print $form->select_country((
GETPOST(
'country_id') !=
'' ?
GETPOST(
'country_id') : $object->country_id),
'country_id');
2545 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
2548 $countrylabel =
getCountry($object->country_id,
'0');
2549 print $countrylabel;
2555 print
'<tr><td class="tdoverflow">'.$form->editfieldkey(
'State',
'state_id',
'', $object, 0).
'</td><td>';
2556 if ($caneditfield) {
2557 print
img_picto(
'',
'state',
'class="pictofixedwidth"');
2558 print $formcompany->select_state_ajax(
'country_id', $object->state_id, $object->country_id,
'state_id');
2560 print $object->state;
2566 print
"<tr>".
'<td>'.$langs->trans(
"PhonePro").
'</td>';
2568 print
img_picto(
'',
'phoning',
'class="pictofixedwidth"');
2569 if ($caneditfield && empty($object->ldap_sid)) {
2570 print
'<input type="text" name="office_phone" class="flat maxwidth200" value="'.$object->office_phone.
'">';
2572 print
'<input type="hidden" name="office_phone" value="'.$object->office_phone.
'">';
2573 print $object->office_phone;
2578 print
"<tr>".
'<td>'.$langs->trans(
"PhoneMobile").
'</td>';
2580 print
img_picto(
'',
'phoning_mobile',
'class="pictofixedwidth"');
2581 if ($caneditfield && empty($object->ldap_sid)) {
2582 print
'<input type="text" name="user_mobile" class="flat maxwidth200" value="'.$object->user_mobile.
'">';
2584 print
'<input type="hidden" name="user_mobile" value="'.$object->user_mobile.
'">';
2585 print $object->user_mobile;
2590 print
"<tr>".
'<td>'.$langs->trans(
"Fax").
'</td>';
2592 print
img_picto(
'',
'phoning_fax',
'class="pictofixedwidth"');
2593 if ($caneditfield && empty($object->ldap_sid)) {
2594 print
'<input type="text" name="office_fax" class="flat maxwidth200" value="'.$object->office_fax.
'">';
2596 print
'<input type="hidden" name="office_fax" value="'.$object->office_fax.
'">';
2597 print $object->office_fax;
2602 print
"<tr>".
'<td'.(
getDolGlobalString(
'USER_MAIL_REQUIRED') ?
' class="fieldrequired"' :
'').
'>'.$langs->trans(
"EMail").
'</td>';
2604 print
img_picto(
'',
'object_email',
'class="pictofixedwidth"');
2605 if ($caneditfield && empty($object->ldap_sid)) {
2606 print
'<input class="minwidth100 maxwidth500 widthcentpercentminusx" type="text" name="email" class="flat" value="'.$object->email.
'">';
2608 print
'<input type="hidden" name="email" value="'.$object->email.
'">';
2609 print $object->email;
2613 if (isModEnabled(
'socialnetworks')) {
2614 foreach ($socialnetworks as $key => $value) {
2615 if ($value[
'active']) {
2616 print
'<tr><td>'.$langs->trans($value[
'label']).
'</td>';
2618 if (!empty($value[
'icon'])) {
2619 print
'<span class="fab '.$value[
'icon'].
' pictofixedwidth"></span>';
2621 if ($caneditfield && empty($object->ldap_sid)) {
2622 print
'<input type="text" name="'.$key.
'" class="flat maxwidth200" value="'.(isset($object->socialnetworks[$key]) ? $object->socialnetworks[$key] :
'').
'">';
2624 print
'<input type="hidden" name="'.$key.
'" value="'.$object->socialnetworks[$key].
'">';
2625 print $object->socialnetworks[$key];
2630 print
'<input type="hidden" name="'.$key.
'" value="'.(isset($object->socialnetworks[$key]) ? $object->socialnetworks[$key] :
'').
'">';
2635 print
'</table><hr><table class="border centpercent">';
2639 print
'<tr><td class="titlefield">'.$langs->trans(
"DefaultWarehouse").
'</td><td>';
2640 print $formproduct->selectWarehouses($object->fk_warehouse,
'fk_warehouse',
'warehouseopen', 1);
2641 print
' <a href="'.DOL_URL_ROOT.
'/product/stock/card.php?action=create&token='.newToken().
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=edit&token='.newToken()).
'"><span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans(
"AddWarehouse").
'"></span></a>';
2646 if (isModEnabled(
'accounting')) {
2648 print
'<td class="titlefieldcreate">'.$langs->trans(
"AccountancyCode").
'</td>';
2650 if ($caneditfield) {
2651 print
'<input type="text" class="flat maxwidth300" name="accountancy_code" value="'.$object->accountancy_code.
'">';
2653 print
'<input type="hidden" name="accountancy_code" value="'.$object->accountancy_code.
'">';
2654 print $object->accountancy_code;
2661 if (isModEnabled(
'agenda')) {
2662 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ColorUser").
'</td>';
2664 if ($caneditfield) {
2665 print $formother->selectColor(GETPOSTISSET(
'color') ?
GETPOST(
'color',
'alphanohtml') : $object->color,
'color', null, 1,
'',
'hideifnotset');
2667 print $formother->showColor($object->color,
'');
2674 print
'<td class="titlefieldcreate">'.$langs->trans(
"Photo").
'</td>';
2676 print $form->showphoto(
'userphoto', $object, 60, 0, $caneditfield,
'photowithmargin',
'small', 1, 0,
'user', 1);
2681 if (isModEnabled(
'categorie') && $user->hasRight(
"categorie",
"read")) {
2682 print
'<tr><td>'.$form->editfieldkey(
'Categories',
'usercats',
'', $object, 0).
'</td>';
2684 print
img_picto(
'',
'category',
'class="pictofixedwidth"');
2685 $cate_arbo = $form->select_all_categories(Categorie::TYPE_USER,
null,
null,
null,
null, 1);
2687 $cats = $c->containing($object->id, Categorie::TYPE_USER);
2688 $arrayselected = array();
2689 foreach ($cats as $cat) {
2690 $arrayselected[] = $cat->id;
2692 if ($caneditfield) {
2693 print $form->multiselectarray(
'usercats', $cate_arbo, $arrayselected,
'', 0,
'', 0,
'90%');
2695 print $form->showCategories($object->id, Categorie::TYPE_USER, 1);
2702 print
'<tr><td>'.$form->editfieldkey(
'DefaultLang',
'default_lang',
'', $object, 0,
'string',
'', 0, 0,
'id', $langs->trans(
"WarningNotLangOfInterface", $langs->transnoentitiesnoconv(
"UserGUISetup"))).
'</td><td colspan="3">'.
"\n";
2703 print
img_picto(
'',
'language',
'class="pictofixedwidth"').$formadmin->select_language($object->lang,
'default_lang', 0,
null,
'1', 0, 0,
'widthcentpercentminusx maxwidth300');
2709 print
'<tr><td>'.$langs->trans(
"Status").
'</td>';
2711 print $object->getLibStatut(4);
2715 if (isModEnabled(
"societe")) {
2716 print
'<tr><td>'.$langs->trans(
"LinkToCompanyContact").
'</td>';
2718 if ($object->socid > 0) {
2720 $societe->fetch($object->socid);
2721 print $societe->getNomUrl(1,
'');
2722 if ($object->contact_id) {
2724 $contact->fetch($object->contact_id);
2725 print
' / <a href="'.DOL_URL_ROOT.
'/contact/card.php?id='.$object->contact_id.
'">'.
img_object($langs->trans(
"ShowContact"),
'contact').
' '.
dol_trunc($contact->getFullName($langs), 32).
'</a>';
2728 print
'<span class="opacitymedium hideonsmartphone">'.$langs->trans(
"ThisUserIsNot").
'</span>';
2730 print
' <span class="opacitymedium hideonsmartphone">('.$langs->trans(
"UseTypeFieldToChange").
')</span>';
2736 if (isModEnabled(
'adherent')) {
2737 $langs->load(
"members");
2738 print
'<tr><td>'.$langs->trans(
"LinkedToDolibarrMember").
'</td>';
2740 if ($object->fk_member) {
2742 $adh->fetch($object->fk_member);
2743 $adh->ref = $adh->login;
2744 print $adh->getNomUrl(1);
2746 print
'<span class="opacitymedium hideonsmartphone">'.$langs->trans(
"UserNotLinkedToMember").
'</span>';
2754 if (isModEnabled(
'multicompany') && is_object($mc)) {
2756 if (!method_exists($mc,
'formObjectOptions')) {
2757 if (empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && !$user->entity) {
2758 print
"<tr>".
'<td>'.$langs->trans(
"Entity").
'</td>';
2759 print
"<td>".$mc->select_entities($object->entity,
'entity',
'', 0, 1,
false,
false, 1);
2760 print
"</td></tr>\n";
2762 print
'<input type="hidden" name="entity" value="'.$conf->entity.
'" />';
2768 $parameters = array(
'colspan' =>
' colspan="2"');
2770 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
2771 print $hookmanager->resPrint;
2772 if (empty($reshook)) {
2773 if ($caneditfield) {
2774 print $object->showOptionals($extrafields,
'edit');
2776 print $object->showOptionals($extrafields,
'view');
2781 print
'<tr><td class="tdtop">'.$langs->trans(
"Signature").
'</td>';
2783 if ($caneditfield) {
2784 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
2786 $doleditor =
new DolEditor(
'signature', $object->signature,
'', 138,
'dolibarr_notes',
'In',
false, $acceptlocallinktomedia, !
getDolGlobalString(
'FCKEDITOR_ENABLE_USERSIGN') ? 0 : 1, ROWS_4,
'90%');
2787 print $doleditor->Create(1);
2799 print
'<table class="border centpercent">';
2805 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"PostOrFunction").
'</td>';
2807 if ($caneditfield) {
2808 print
'<input type="text" class="minwidth300 maxwidth500" name="job" value="'.dol_escape_htmltag($object->job).
'">';
2810 print
'<input type="hidden" name="job" value="'.dol_escape_htmltag($object->job).
'">';
2816 print
'<tr><td>'.$langs->trans(
"WeeklyHours").
'</td>';
2818 if ($caneditfield) {
2819 print
'<input size="8" type="text" name="weeklyhours" value="'.price2num(
GETPOST(
'weeklyhours') ?
GETPOST(
'weeklyhours') : $object->weeklyhours).
'">';
2827 if ((empty($user->socid) && in_array($id, $childids))
2828 || (isModEnabled(
'salaries') && $user->hasRight(
"salaries",
"readall"))
2829 || (isModEnabled(
'hrm') && $user->hasRight(
"hrm",
"employee",
"read"))) {
2830 $langs->load(
"salaries");
2833 print
'<tr><td>'.$langs->trans(
"Salary").
'</td>';
2835 print
img_picto(
'',
'salary',
'class="pictofixedwidth paddingright"').
'<input size="8" type="text" name="salary" value="'.
price2num(
GETPOST(
'salary') ?
GETPOST(
'salary') : $object->salary).
'">';
2841 $text = $langs->trans(
"THM");
2842 print $form->textwithpicto($text, $langs->trans(
"THMDescription"), 1,
'help',
'classthm');
2845 if ($caneditfield) {
2846 print
'<input size="8" type="text" name="thm" value="'.price2num(
GETPOST(
'thm') ?
GETPOST(
'thm') : $object->thm).
'">';
2848 print($object->thm !=
'' ?
price($object->thm,
'', $langs, 1, -1, -1, $conf->currency) :
'');
2855 $text = $langs->trans(
"TJM");
2856 print $form->textwithpicto($text, $langs->trans(
"TJMDescription"), 1,
'help',
'classthm');
2859 if ($caneditfield) {
2860 print
'<input size="8" type="text" name="tjm" value="'.price2num(
GETPOST(
'tjm') ?
GETPOST(
'tjm') : $object->tjm).
'">';
2862 print($object->tjm !=
'' ?
price($object->tjm,
'', $langs, 1, -1, -1, $conf->currency) :
'');
2869 print
'<tr><td>'.$langs->trans(
"DateEmployment").
'</td>';
2871 if ($caneditfield) {
2872 print $form->selectDate($dateemployment ? $dateemployment : $object->dateemployment,
'dateemployment', 0, 0, 1,
'formdateemployment', 1, 1, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"from"));
2877 if ($dateemployment && $dateemploymentend) {
2881 if ($caneditfield) {
2882 print $form->selectDate($dateemploymentend ? $dateemploymentend : $object->dateemploymentend,
'dateemploymentend', 0, 0, 1,
'formdateemploymentend', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"));
2890 print
'<tr><td>'.$langs->trans(
"DateOfBirth").
'</td>';
2892 if ($caneditfield) {
2893 echo $form->selectDate($dateofbirth ? $dateofbirth : $object->birth,
'dateofbirth', 0, 0, 1,
'updateuser', 1, 0, 0,
'',
'',
'',
'', 1,
'',
'',
'tzserver');
2904 print
'<div class="center">';
2905 print
'<input value="'.$langs->trans(
"Save").
'" class="button button-save" type="submit" name="save">';
2906 print
' ';
2907 print
'<input value="'.$langs->trans(
"Cancel").
'" class="button button-cancel" type="submit" name="cancel">';
2913 if ($action !=
'edit' && $action !=
'presend') {
2914 print
'<div class="fichecenter"><div class="fichehalfleft">';
2919 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".$object->id;
2920 $genallowed = $user->hasRight(
"user",
"user",
"read");
2921 $delallowed = $user->hasRight(
"user",
"user",
"write");
2923 print $formfile->showdocuments(
'user', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0,
'', 0,
'', empty($soc->default_lang) ?
'' : $soc->default_lang);
2924 $somethingshown = $formfile->numoffiles;
2927 $linktoelem = $form->showLinkToObjectBlock($object,
null,
null);
2928 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
2930 print
'</div><div class="fichehalfright">';
2933 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
2935 $somethingshown =
$formactions->showactions($object,
'user', $socid, 1,
'listactions', 0,
'',
'', $object->id);
2937 print
'</div></div>';
2940 if (isModEnabled(
'ldap') && !empty($object->ldap_sid)) {
2947include_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
2949if (isModEnabled(
'api')) {
if(preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if(preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if($action=='set') elseif( $action=='specimen') elseif($action=='setmodel') elseif( $action=='del') elseif($action=='setdoc') $formactions
View.
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='')
Convert a html select field into an ajax combobox.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage members of a foundation.
Class to manage categories.
Class to manage a WYSIWYG editor.
Class to manage warehouses.
Class to manage LDAP features.
const SYNCHRO_LDAP_TO_DOLIBARR
Ldap to Dolibarr synchronization.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage user groups.
Class to manage Dolibarr users.
getCountry($searchkey, $withcode='', $dbtouse=0, $outputlangs='', $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
dol_delete_dir_recursive($dir, $count=0, $nophperrors=0, $onlysub=0, &$countdeleted=0, $indexdatabase=1, $nolog=0)
Remove a directory $dir and its subdirectories (or only files and subdirectories)
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1, $nolog=0)
Remove a file or several files with a mask.
dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disablevirusscan=0, $uploaderrorcode=0, $nohook=0, $varfiles='addedfile', $upload_dir='')
Make control on an uploaded file from an GUI page and move it to final destination.
acceptLocalLinktoMedia()
Check the syntax of some PHP code.
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
picto_from_langcode($codelang, $moreatt='', $notitlealt=0)
Return img flag of country for a language code or country code.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
showValueWithClipboardCPButton($valuetocopy, $showonlyonhover=1, $texttoshow='')
Create a button to copy $valuetocopy in the clipboard (for copy and paste feature).
GETPOSTINT($paramname, $method=0)
Return value of a param into GET or POST supervariable.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $disabled='', $morecss='classlink button bordertransp', $jsonopen='', $backtopagejsfields='', $accesskey='')
Return HTML code to output a button to open a dialog popup box.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dol_get_fiche_end($notab=0)
Return tab footer of a card.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_email($email, $cid=0, $socid=0, $addlink=0, $max=64, $showinvalid=1, $withpicto=0)
Show EMail link formatted for HTML output.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_set_focus($selector)
Set focus onto field with selector (similar behaviour of 'autofocus' HTML5 tag)
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
getArrayOfSocialNetworks()
Get array of social network dictionary.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information for admin users or standard users.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
image_format_supported($file, $acceptsvg=0)
Return if a filename is file name of a supported image format.
dolJSToSetRandomPassword($htmlname, $htmlnameofbutton='generate_token', $generic=1)
Ouput javacript to autoset a generated password using default module into a HTML element.
getRandomPassword($generic=false, $replaceambiguouschars=null, $length=32)
Return a generated password using default module.
dol_verifyHash($chain, $hash, $type='0')
Compute a hash and compare it to the given one For backward compatibility reasons,...
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
user_prepare_head(User $object)
Prepare array with list of tabs.