40require
'../main.inc.php';
52require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
53require_once DOL_DOCUMENT_ROOT.
'/user/class/usergroup.class.php';
54require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
55require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
56require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
57require_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
58require_once DOL_DOCUMENT_ROOT.
'/core/lib/usergroups.lib.php';
59require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
60require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
61require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
62require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
63require_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
65 require_once DOL_DOCUMENT_ROOT.
'/core/class/ldap.class.php';
68 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
71 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
74 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
78$langs->loadLangs(array(
'users',
'companies',
'ldap',
'admin',
'hrm',
'stocks',
'other'));
81$action =
GETPOST(
'action',
'aZ09');
82$mode =
GETPOST(
'mode',
'alpha');
83$confirm =
GETPOST(
'confirm',
'alpha');
85$cancel =
GETPOST(
'cancel',
'alpha');
86$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'usercard';
87$backtopage =
GETPOST(
'backtopage');
88$backtopageforcancel =
GETPOST(
'backtopageforcancel');
89$forcepasswordchange =
GETPOSTINT(
'forcepasswordchange');
91if (empty($id) && $action !=
'add' && $action !=
'create') {
101$childids = $user->getAllChildIds(1);
106$extrafields->fetch_name_optionals_label(
$object->table_element);
111$hookmanager->initHooks(array(
'usercard',
'globalcard'));
118 $res =
$object->fetch($id,
'',
'', 1);
123if ($user->socid > 0) {
124 $socid = $user->socid;
130$permissiontoadd = (!empty($user->admin) || $user->hasRight(
"user",
"user",
"write")) && (empty($user->socid) || $user->socid ==
$object->socid);
131$permissiontoread = (!empty($user->admin) || $user->hasRight(
"user",
"user",
"read")) && (empty($user->socid) || $user->socid ==
$object->socid);
132$permissiontoedit = (!empty($user->admin) || $user->hasRight(
"user",
"user",
"write")) && (empty($user->socid) || $user->socid ==
$object->socid);
133$permissiontodisable = (!empty($user->admin) || $user->hasRight(
"user",
"user",
"delete")) && (empty($user->socid) || $user->socid ==
$object->socid);
134$permissiontoreadgroup = $permissiontoread;
135$permissiontoeditgroup = $permissiontoedit;
137 $permissiontoreadgroup = (!empty($user->admin) || $user->hasRight(
"user",
"group_advance",
"read")) && (empty($user->socid) || $user->socid ==
$object->socid);
138 $permissiontoeditgroup = (!empty($user->admin) || $user->hasRight(
"user",
"group_advance",
"write")) && (empty($user->socid) || $user->socid ==
$object->socid);
141$permissiontoclonesuperadmin = ($permissiontoadd && empty($user->entity));
142$permissiontocloneadmin = ($permissiontoadd && !empty($user->admin));
143$permissiontocloneuser = $permissiontoadd;
146 $permissiontoclonesuperadmin =
false;
147 $permissiontocloneadmin =
false;
148 $permissiontocloneuser =
false;
151if ($user->id != $id && !$permissiontoread) {
155$caneditpasswordandsee =
false;
156$caneditpasswordandsend =
false;
159$permissiontoeditpasswordandsee =
false;
160$permissiontoeditpasswordandsend =
false;
163 $permissiontoedit = ((($user->id ==
$id) && $user->hasRight(
"user",
"self",
"write")) || (($user->id != $id) && $user->hasRight(
"user",
"user",
"write"))) && (empty($user->socid) || $user->socid ==
$object->socid);
164 $permissiontoeditpasswordandsee = ((($user->id ==
$id) && $user->hasRight(
"user",
"self",
"password")) || (($user->id != $id) && $user->hasRight(
"user",
"user",
"password") && $user->admin))&& (empty($user->socid) || $user->socid ==
$object->socid);
165 $permissiontoeditpasswordandsend = ((($user->id ==
$id) && $user->hasRight(
"user",
"self",
"password")) || (($user->id != $id) && $user->hasRight(
"user",
"user",
"password")))&& (empty($user->socid) || $user->socid ==
$object->socid);
168$passwordismodified =
false;
176$parameters = array(
'id' => $id,
'socid' => $socid,
'group' => $group,
'caneditgroup' => $permissiontoeditgroup);
177$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
182if (empty($reshook)) {
183 $backurlforlist = DOL_URL_ROOT.
'/user/list.php';
185 if (empty($backtopage) || ($cancel && empty($id))) {
186 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
187 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
188 $backtopage = $backurlforlist;
190 $backtopage = DOL_URL_ROOT.
'/user/card.php?id='.((!empty($id) &&
$id > 0) ? $id :
'__ID__');
196 if (!empty($backtopageforcancel)) {
197 header(
"Location: ".$backtopageforcancel);
199 } elseif (!empty($backtopage)) {
200 header(
"Location: ".$backtopage);
206 if ($action ==
'confirm_disable' && $confirm ==
"yes" && $permissiontodisable) {
207 if ($id != $user->id) {
209 if (
$object->admin && empty($user->admin)) {
212 setEventMessages($langs->trans(
"OnlyAdminUsersCanDisableAdminUsers"),
null,
'errors');
215 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$id);
221 if ($action ==
'confirm_enable' && $confirm ==
"yes" && $permissiontodisable) {
224 if ($id != $user->id) {
227 if (!empty(
$conf->file->main_limit_users)) {
228 $nb =
$object->getNbOfUsers(
"active");
229 if ($nb >=
$conf->file->main_limit_users) {
231 setEventMessages($langs->trans(
"YourQuotaOfUsersIsReached"),
null,
'errors');
237 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$id);
243 if ($action ==
'confirm_delete' && $confirm ==
"yes" && $permissiontodisable) {
244 if ($id != $user->id) {
245 if (!GETPOSTISSET(
'token')) {
246 print
'Error, token required for this critical operation';
254 $result =
$object->delete($user);
256 $langs->load(
"errors");
260 header(
"Location: ".DOL_URL_ROOT.
"/user/list.php?restore_lastsearch_values=1");
267 if ($action ==
'add' && $permissiontoadd) {
281 if (!empty(
$conf->file->main_limit_users)) {
282 $nb =
$object->getNbOfUsers(
"active");
283 if ($nb >=
$conf->file->main_limit_users) {
285 setEventMessages($langs->trans(
"YourQuotaOfUsersIsReached"),
null,
'errors');
295 $object->national_registration_number =
GETPOST(
"national_registration_number",
'alphanohtml');
310 $object->socialnetworks = array();
311 foreach ($socialnetworks as $key => $value) {
312 if (
GETPOST($key,
'alphanohtml')) {
318 $object->email = preg_replace(
'/\s+/',
'',
GETPOST(
"email",
'alphanohtml'));
325 if (
$object->signature ===
'ErrorTooManyLinksIntoHTMLString') {
327 $langs->load(
"errors");
328 setEventMessages($langs->trans(
'ErrorTooManyLinksIntoHTMLString'),
null,
'errors');
331 $object->accountancy_code =
GETPOST(
"accountancy_code",
'alphanohtml');
351 $object->color =
GETPOST(
"color",
'alphanohtml') !=
'' ? str_replace(
'#',
'', (
string)
GETPOST(
"color",
'alphanohtml')) :
'';
353 $object->dateemployment = $dateemployment;
354 $object->dateemploymentend = $dateemploymentend;
355 $object->datestartvalidity = $datestartvalidity;
356 $object->dateendvalidity = $dateendvalidity;
358 $object->force_pass_change = $forcepasswordchange;
365 $ret = $extrafields->setOptionalsFromPost(
null, $object);
379 $object->entity = ($entity ==
'' ? 1 : $entity);
383 $object->entity = ($entity ==
'' ? 1 : $entity);
394 if (
GETPOST(
'password',
'password')) {
395 $resPass =
$object->setPassword($user,
GETPOST(
'password',
'password'));
397 if (is_int($resPass) && $resPass < 0) {
398 $langs->load(
"errors");
405 $usercats =
GETPOST(
'usercats',
'array:int');
406 $object->setCategories($usercats);
410 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$id);
414 $langs->load(
"errors");
423 if (($action ==
'addgroup' || $action ==
'removegroup') && $permissiontoeditgroup) {
426 $editgroup->fetch($group);
427 $editgroup->oldcopy = clone $editgroup;
431 if ($action ==
'addgroup') {
432 $result =
$object->SetInGroup($group, $editgroup->entity);
434 if ($action ==
'removegroup') {
435 $result =
$object->RemoveFromGroup($group, $editgroup->entity);
446 if ($action ==
'update' && ($permissiontoedit || $permissiontoeditpasswordandsee)) {
447 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
449 if ($permissiontoedit) {
452 if (!
GETPOST(
"lastname",
'alpha')) {
457 if (!
GETPOST(
"login",
'alpha')) {
474 if (GETPOSTISSET(
"ref_employee")) {
478 if (GETPOSTISSET(
"national_registration_number")) {
479 $object->national_registration_number =
GETPOST(
"national_registration_number",
'alphanohtml');
482 if ($permissiontoeditpasswordandsee) {
485 if ($permissiontoeditpasswordandsee || $user->hasRight(
"api",
"apikey",
"generate")) {
488 if (!empty($user->admin) && $user->id != $id) {
493 if ($user->admin && !
$object->ldap_sid) {
506 $object->socialnetworks = array();
507 foreach ($socialnetworks as $key => $value) {
508 if (
GETPOST($key,
'alphanohtml')) {
514 $object->email = preg_replace(
'/\s+/',
'',
GETPOST(
"email",
'alphanohtml'));
521 if (
$object->signature ===
'ErrorTooManyLinksIntoHTMLString') {
523 $langs->load(
"errors");
524 setEventMessages($langs->trans(
'ErrorTooManyLinksIntoHTMLString'),
null,
'errors');
527 $object->accountancy_code =
GETPOST(
"accountancy_code",
'alphanohtml');
545 $object->color =
GETPOST(
"color",
'alphanohtml') !=
'' ? str_replace(
'#',
'', (
string)
GETPOST(
"color",
'alphanohtml')) :
'';
546 $object->dateemployment = $dateemployment;
547 $object->dateemploymentend = $dateemploymentend;
548 $object->datestartvalidity = $datestartvalidity;
549 $object->dateendvalidity = $dateendvalidity;
551 $object->force_pass_change = $forcepasswordchange;
560 if (
isModEnabled(
'multicompany') && empty($user->entity) && !empty($user->admin)) {
574 $ret = $extrafields->setOptionalsFromPost(
null, $object,
'@GETPOSTISSET');
582 if (!empty($_FILES[
'photo'][
'name'])) {
586 if (
$object->id == $user->id) {
591 $langs->load(
"errors");
593 dol_syslog($langs->transnoentities(
"ErrorBadImageFormat"), LOG_INFO);
598 $passwordismodified = 0;
601 $passwordismodified = 1;
608 if (
$db->errno() ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
609 $langs->load(
"errors");
610 setEventMessages($langs->trans(
"ErrorUpdateCanceledDueToDuplicatedUniqueValue",
$object->login),
null,
'errors');
618 if (!$error && GETPOSTISSET(
'contactid')) {
622 if ($contactid > 0) {
624 $contact->fetch($contactid);
626 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user";
627 $sql .=
" SET fk_socpeople=".((int) $contactid);
628 if (!empty($contact->socid)) {
629 $sql .=
", fk_soc=".((int) $contact->socid);
630 } elseif ($socid > 0) {
631 $sql .=
", fk_soc = null";
632 setEventMessages($langs->trans(
"WarningUserDifferentContactSocid"),
null,
'warnings');
634 $sql .=
" WHERE rowid = ".((int)
$object->id);
635 } elseif ($socid > 0) {
636 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user";
637 $sql .=
" SET fk_socpeople=NULL, fk_soc=".((int) $socid);
638 $sql .=
" WHERE rowid = ".((int)
$object->id);
640 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user";
641 $sql .=
" SET fk_socpeople=NULL, fk_soc=NULL";
642 $sql .=
" WHERE rowid = ".((int)
$object->id);
645 $resql =
$db->query($sql);
652 if (!$error && !count(
$object->errors)) {
654 $fileimg =
$conf->user->dir_output.
'/'.
get_exdir(0, 0, 0, 0, $object,
'user').
'photos/'.
$object->oldcopy->photo;
657 $dirthumbs =
$conf->user->dir_output.
'/'.
get_exdir(0, 0, 0, 0, $object,
'user').
'photos/thumbs';
661 if (isset($_FILES[
'photo'][
'tmp_name']) && trim($_FILES[
'photo'][
'tmp_name'])) {
662 $dir =
$conf->user->dir_output.
'/'.
get_exdir(0, 0, 0, 1, $object,
'user').
'/photos';
669 $result =
dol_move_uploaded_file($_FILES[
'photo'][
'tmp_name'], $newfile, 1, 0, $_FILES[
'photo'][
'error']);
671 if (!($result > 0)) {
679 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
688 $langs->load(
"errors");
689 setEventMessages($langs->trans(
"ErrorFailedToCreateDir", $dir), $mesgs,
'errors');
694 if (!$error && !count(
$object->errors)) {
696 $categories =
GETPOST(
'usercats',
'array:int');
697 $object->setCategories($categories);
700 if (!$error && !count(
$object->errors)) {
704 $login = $_SESSION[
"dol_login"];
707 $langs->load(
"errors");
708 setEventMessages($langs->transnoentitiesnoconv(
"WarningYourLoginWasModifiedPleaseLogin"),
null,
'warnings');
710 if ($passwordismodified &&
$object->login == $user->login) {
712 $langs->load(
"errors");
713 setEventMessages($langs->transnoentitiesnoconv(
"WarningYourPasswordWasModifiedPleaseLogin"),
null,
'warnings');
714 header(
"Location: ".DOL_URL_ROOT.
'/user/card.php?id='.
$object->id);
722 if ($permissiontoeditpasswordandsee) {
723 dol_syslog(
"Not allowed to change fields, only password");
727 if (
GETPOST(
"password",
"password")) {
730 $ret =
$object->setPassword($user,
GETPOST(
"password",
"password"));
731 if (is_int($ret) && $ret < 0) {
740 if ((($action ==
'confirm_password' && $confirm ==
'yes' && $permissiontoeditpasswordandsee)
741 || ($action ==
'confirm_passwordsend' && $confirm ==
'yes' && $permissiontoeditpasswordandsend))
745 $newpassword =
$object->setPassword($user,
'');
746 if (is_int($newpassword) && $newpassword < 0) {
748 setEventMessages($langs->trans(
"ErrorFailedToSetNewPassword"),
null,
'errors');
751 if ($action ==
'confirm_passwordsend') {
752 if (
$object->send_password($user, $newpassword) > 0) {
758 setEventMessages($langs->trans(
"PasswordChangedTo", $newpassword),
null,
'warnings');
764 if ($action ==
'adduserldap' && $permissiontoadd) {
765 $selecteduser =
GETPOST(
'users');
767 $required_fields = array(
784 $arrayofsocialnetworks = array(
'skype',
'twitter',
'facebook',
'linkedin');
785 foreach ($arrayofsocialnetworks as $socialnetwork) {
791 $result = $ldap->connectBind();
794 $required_fields = array_unique(array_values(array_filter($required_fields,
"dol_validElement")));
799 if (is_array($ldapusers)) {
800 foreach ($ldapusers as $key => $attribute) {
812 $ldap_social = array();
815 $arrayofsocialnetworks = array(
'skype',
'twitter',
'facebook',
'linkedin');
816 foreach ($arrayofsocialnetworks as $socialnetwork) {
817 $ldap_social[$socialnetwork] = $attribute[
getDolGlobalString(
'LDAP_FIELD_'.strtoupper($socialnetwork))];
827 if ($action ==
'confirm_clone' && $confirm !=
'yes') {
830 if ($action ==
'confirm_clone' && $confirm ==
'yes' && $permissiontocloneuser) {
834 setEventMessages($langs->trans(
'ErrorNoCloneWithoutEmail'),
null,
'errors');
842 $clone->api_key =
'';
844 $parts = explode(
' ',
GETPOST(
'clone_name'), 2);
845 $clone->firstname = $parts[0];
846 $clone->lastname = isset($parts[1]) ? $parts[1] :
'';
848 $clone->login = substr($parts[0], 0, 1).$parts[1];
851 $clone->context[
'createfromclone'] =
'createfromclone';
852 $id = $clone->create($user);
853 $refalreadyexists = 0;
856 $result = $clone->cloneRights(
$object->id, $id);
859 if (
GETPOST(
'clone_categories')) {
860 $result = $clone->cloneCategories(
$object->id, $id);
868 if ($clone->error ==
'ErrorProductAlreadyExists') {
872 $mesg = $langs->trans(
"ErrorProductAlreadyExists", $clone->ref);
873 $mesg .=
' <a href="' . $_SERVER[
"PHP_SELF"] .
'?ref=' . $clone->ref .
'">' . $langs->trans(
"ShowCardHere") .
'</a>.';
876 setEventMessages(empty($clone->error) ?
'' : $langs->trans($clone->error), $clone->errors,
'errors');
880 unset($clone->context[
'createfromclone']);
887 header(
"Location: " . $_SERVER[
"PHP_SELF"] .
"?id=" . $id);
898 $triggersendname =
'USER_SENTBYMAIL';
900 $mode =
'emailfromuser';
901 $trackid =
'use'.$id;
902 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
905 $upload_dir =
$conf->user->dir_output;
906 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
909 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
929$sql =
"SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.
'user WHERE entity IN ('.
getEntity(
'user').
')';
930$resql =
$db->query($sql);
932 $obj =
$db->fetch_object($resql);
934 $nbofusers = $obj->nb;
942 $title = $person_name.
" - ".$langs->trans(
'Card');
945 $title = $langs->trans(
"NewEmployee");
947 $title = $langs->trans(
"NewUser");
953llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-user page-card');
955if ($action ==
'create' || $action ==
'adduserldap') {
958 print
'<span class="opacitymedium">'.$langs->trans(
"CreateInternalUserDesc", $langs->transnoentities(
"CreateExternalUser")).
"</span><br>\n";
967 $result = $ldap->connectBind();
969 $required_fields = array(
989 $required_fields = array_unique(array_values(array_filter($required_fields,
"dol_validElement")));
994 if (is_array($ldapusers)) {
995 foreach ($ldapusers as $key => $ldapuser) {
998 foreach ($required_fields as $value) {
1000 $label .= $value.
"=******* ";
1002 $label .= $value.
"=".$ldapuser[$value].
" ";
1005 $liste[$key] = $label;
1015 print
"\n\n<!-- Form liste LDAP debut -->\n";
1017 print
'<form name="add_user_ldap" action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
1018 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1019 print
'<table class="border centpercent"><tr>';
1020 print
'<td width="160">';
1021 print $langs->trans(
"LDAPUsers");
1024 print
'<input type="hidden" name="action" value="adduserldap">';
1025 if (is_array($liste) && count($liste)) {
1026 print $form->selectarray(
'users', $liste,
'', 1, 0, 0,
'', 0, 0, 0,
'',
'maxwidth500');
1029 print
'</td><td class="center">';
1030 print
'<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans(
'Get')).
'"'.(count($liste) ?
'' :
' disabled').
'>';
1031 print
'</td></tr></table>';
1034 print
"\n<!-- Form liste LDAP fin -->\n\n";
1039 print
'<form action="'.$_SERVER[
'PHP_SELF'].
'" method="POST" name="createuser">';
1040 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1041 print
'<input type="hidden" name="action" value="add">';
1042 if (!empty($ldap_sid)) {
1043 print
'<input type="hidden" name="ldap_sid" value="'.dol_escape_htmltag($ldap_sid).
'">';
1045 print
'<input type="hidden" name="entity" value="'.$conf->entity.
'">';
1051 print
'<table class="border centpercent">';
1055 print
'<tr><td><label for="civility_code">'.$langs->trans(
"UserTitle").
'</label></td><td>';
1056 print $formcompany->select_civility(GETPOSTISSET(
"civility_code") ?
GETPOST(
"civility_code",
'aZ09') :
$object->civility_code,
'civility_code');
1062 print
'<td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans(
"Lastname").
'</span></td>';
1064 if (!empty($ldap_lastname)) {
1065 print
'<input type="hidden" id="lastname" name="lastname" value="'.dol_escape_htmltag($ldap_lastname).
'">';
1066 print $ldap_lastname;
1068 print
'<input class="minwidth100 maxwidth150onsmartphone createloginauto" type="text" id="lastname" name="lastname" value="'.dol_escape_htmltag(
GETPOST(
'lastname',
'alphanohtml')).
'">';
1073 print
'<tr><td>'.$langs->trans(
"Firstname").
'</td>';
1075 if (!empty($ldap_firstname)) {
1076 print
'<input type="hidden" name="firstname" value="'.dol_escape_htmltag($ldap_firstname).
'">';
1077 print $ldap_firstname;
1079 print
'<input id="firstname" class="minwidth100 maxwidth150onsmartphone createloginauto" type="text" name="firstname" value="'.dol_escape_htmltag(
GETPOST(
'firstname',
'alphanohtml')).
'">';
1084 print
'<tr><td><span class="fieldrequired">'.$langs->trans(
"Login").
'</span></td>';
1086 if (!empty($ldap_login)) {
1087 print
'<input type="hidden" name="login" value="'.dol_escape_htmltag($ldap_login).
'">';
1089 } elseif (!empty($ldap_loginsmb)) {
1090 print
'<input type="hidden" name="login" value="'.dol_escape_htmltag($ldap_loginsmb).
'">';
1091 print $ldap_loginsmb;
1093 print
'<input id="login" class="maxwidth200 maxwidth150onsmartphone" maxsize="24" type="text" name="login" value="'.dol_escape_htmltag(
GETPOST(
'login',
'alphanohtml')).
'" spellcheck="false">';
1097 if (!empty(
$conf->use_javascript_ajax)) {
1101 $charforseparator =
getDolGlobalString(
"MAIN_USER_SEPARATOR_CHAR_FOR_GENERATED_LOGIN",
'.');
1102 if ($charforseparator ==
'none') {
1103 $charforseparator =
'';
1106 jQuery(document).ready(function() {
1107 $(".createloginauto").on("keyup", function() {
1108 console.log(".createloginauto change: We generate login when we have a lastname");
1110 lastname = $("#lastname").val().toLowerCase();
1113 print
' firstname = $("#firstname").val().toLowerCase().replace(/\s+/g, \'\').trim()[0];';
1114 $charforseparator =
'';
1116 print
' firstname = $("#firstname").val().toLowerCase().replace(/\s+/g, \'\').trim()[0];';
1118 print
' firstname = $("#firstname").val().toLowerCase().replace(/\s+/g, \'\').trim();';
1124 login = firstname + \''.
dol_escape_js($charforseparator).
'\';
1126 login += lastname.replace(/\s+/g, \
'\').trim();
1128 $(
"#login").val(login);
1134 $generated_password = '';
1135 if (empty($ldap_sid)) { // ldap_sid is for activedirectory
1136 $generated_password = getRandomPassword(false);
1138 $password = (GETPOSTISSET('password
') ? GETPOST('password
') : $generated_password);
1141 if (!empty($user->admin)) {
1142 print '<tr><td>
'.$form->textwithpicto($langs->trans("Administrator"), $langs->trans("AdministratorDesc"), 1, 'help
').'</td>
';
1144 print $form->selectyesno('admin
', GETPOST('admin
'), 1, false, 0, 1);
1146 if (isModEnabled('multicompany
') && !$user->entity) {
1147 if (!empty($conf->use_javascript_ajax)) {
1148 print '<script
type=
"text/javascript">
1150 $(
"select[name=admin]").change(
function() {
1151 if ( $(
this).val() == 0 ) {
1152 $(
"input[name=superadmin]")
1153 .prop(
"disabled",
true)
1154 .prop(
"checked",
false);
1155 $(
"select[name=entity]")
1156 .prop(
"disabled",
false);
1158 $(
"input[name=superadmin]")
1159 .prop(
"disabled",
false);
1162 $(
"input[name=superadmin]").change(
function() {
1163 if ( $(
this).is(
":checked") ) {
1164 $(
"select[name=entity]")
1165 .prop(
"disabled",
true);
1167 $(
"select[name=entity]")
1168 .prop(
"disabled",
false);
1174 $checked = (GETPOSTINT('superadmin
') ? ' checked
' : '');
1175 $disabled = (GETPOSTINT('superadmin
') ? '' : ' disabled');
1176 print '<input
type=
"checkbox" name=
"superadmin" id=
"superadmin" value=
"1"'.$checked.$disabled.' /> <label
for=
"superadmin">
'.$langs->trans("SuperAdministrator").'</span>
';
1178 print "</td></tr>\n";
1182 print '<tr><td>
'.$langs->trans("Gender").'</td>
';
1184 $arraygender = array('man
' => $langs->trans("Genderman"), 'woman
' => $langs->trans("Genderwoman"), 'other
' => $langs->trans("Genderother"));
1185 print $form->selectarray('gender
', $arraygender, GETPOST('gender
'), 1);
1189 $defaultemployee = '1
';
1191 print '<td>
'.$langs->trans('Employee
').'</td><td>
';
1192 print '<input
type=
"checkbox" name=
"employee" value=
"1"'.(GETPOST('employee
') == '1
' ? ' checked=
"checked"' : (($defaultemployee && !GETPOSTISSET('login
')) ? ' checked=
"checked"' : '')).'>
';
1193 //print $form->selectyesno("employee", (GETPOST('employee
') != '' ?GETPOST('employee
') : $defaultemployee), 1);
1197 print '<tr><td
class=
"titlefieldcreate">
'.$langs->trans("HierarchicalResponsible").'</td>
';
1199 print img_picto('', 'user', 'class=
"pictofixedwidth"').$form->select_dolusers($object->fk_user, 'fk_user
', 1, array($object->id), 0, '', '', (string) $conf->entity, 0, 0, '', 0, '', 'maxwidth300 widthcentpercentminusx
');
1203 // Expense report validator
1204 if (isModEnabled('expensereport
')) {
1205 print '<tr><td
class=
"titlefieldcreate">
';
1206 $text = $langs->trans("ForceUserExpenseValidator");
1207 print $form->textwithpicto($text, $langs->trans("ValidatorIsSupervisorByDefault"), 1, 'help
');
1210 print img_picto('', 'user', 'class=
"pictofixedwidth"').$form->select_dolusers($object->fk_user_expense_validator, 'fk_user_expense_validator
', 1, array($object->id), 0, '', '', (string) $conf->entity, 0, 0, '', 0, '', 'maxwidth300 widthcentpercentminusx
');
1215 // Holiday request validator
1216 if (isModEnabled('holiday
')) {
1217 print '<tr><td
class=
"titlefieldcreate">
';
1218 $text = $langs->trans("ForceUserHolidayValidator");
1219 print $form->textwithpicto($text, $langs->trans("ValidatorIsSupervisorByDefault"), 1, 'help
');
1222 print img_picto('', 'user', 'class=
"pictofixedwidth"').$form->select_dolusers($object->fk_user_holiday_validator, 'fk_user_holiday_validator
', 1, array($object->id), 0, '', '', (string) $conf->entity, 0, 0, '', 0, '', 'maxwidth300 widthcentpercentminusx
');
1228 print '<tr><td>
'.$langs->trans("ExternalUser").' ?</td>
';
1230 print $form->textwithpicto($langs->trans("Internal"), $langs->trans("InternalExternalDesc"), 1, 'help
', '', 0, 2);
1234 print '</
table><hr><
table class=
"border centpercent">
';
1238 print '<tr><td
class=
"titlefieldcreate">
'.$langs->trans("RangeOfLoginValidity").'</td>
';
1240 print $form->selectDate($datestartvalidity, 'datestartvalidity
', 0, 0, 1, 'formdatestartvalidity
', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("from"));
1244 print $form->selectDate($dateendvalidity, 'dateendvalidity
', 0, 0, 1, 'formdateendvalidity
', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
1248 // Force update on next login -- only on dolibarr auth context
1249 if ($_SESSION["dol_authmode"] == 'dolibarr
') {
1250 print '<tr><td
class=
"titlefieldcreate">
'.$form->textwithpicto($langs->trans("PasswordToChange"), $langs->trans("ForcePasswordChange")).'</td>
';
1252 //$permissiontoselfeditpassword = $object->hasRight('user', 'self', 'password
');
1253 $permissiontoselfeditpassword = 1; // In creation, we suppose it to true
1254 if ($permissiontoselfeditpassword) { // @phpstan-ignore-line because value is forced
1255 print '<input
type=
"checkbox" name=
"forcepasswordchange" id=
"forcepasswordchange" value=
"1"'.(GETPOST('forcepasswordchange
') == '1
' ? ' checked=
"checked"' : '').'>
';
1256 print '<label
class=
"opacitymedium" for=
"forcepasswordchange">
'.$langs->trans("AtNextLogin").'</label>
';
1258 print '<input
type=
"checkbox" name=
"forcepasswordchange" value=
"1" class=
"colorgrey valignmiddle" disabled>
';
1259 print $form->textwithpicto('<span
class=
"opacitymedium">
'.$langs->trans("NotPossible").'</span>
', $langs->trans("UserDoesNotHaveRightsToChangeHisPassword"));
1266 print '<tr><td
class=
"fieldrequired">
'.$langs->trans("Password").'</td>
';
1269 if (preg_match('/ldap/
', $dolibarr_main_authentication)) {
1270 $valuetoshow .= ($valuetoshow ? ' +
' : '').$langs->trans("PasswordOfUserInLDAP").' (hidden)
';
1272 if (preg_match('/http/
', $dolibarr_main_authentication)) {
1273 $valuetoshow .= ($valuetoshow ? ' +
' : '').$langs->trans("HTTPBasicPassword");
1275 if (preg_match('/dolibarr/
', $dolibarr_main_authentication) || preg_match('/forceuser/
', $dolibarr_main_authentication)) {
1276 if (!empty($ldap_pass)) { // For very old system compatibility. Now clear password can't be viewed from LDAP read
1277 $valuetoshow .= ($valuetoshow ?
' + ' :
'').
'<input type="hidden" name="password" value="'.
dol_escape_htmltag($ldap_pass).
'">';
1278 $valuetoshow .= preg_replace(
'/./i',
'*', $ldap_pass);
1281 $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" spellcheck="false">';
1282 if (!empty(
$conf->use_javascript_ajax)) {
1283 $valuetoshow .=
img_picto($langs->transnoentities(
'Generate'),
'refresh',
'id="generate_password" class="linkobject paddingleft"');
1289 $parameters = array(
'valuetoshow' => $valuetoshow,
'password' => $password,
'caneditpasswordandsee' => $permissiontoeditpasswordandsee,
'caneditpasswordandsend' => $permissiontoeditpasswordandsend);
1290 $reshook = $hookmanager->executeHooks(
'printUserPasswordField', $parameters, $object, $action);
1292 $valuetoshow = $hookmanager->resPrint;
1294 $valuetoshow .= $hookmanager->resPrint;
1304 print
'<tr><td>'.$langs->trans(
"ApiKey").
'</td>';
1306 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" spellcheck="false">';
1307 if (!empty(
$conf->use_javascript_ajax)) {
1308 print
img_picto($langs->transnoentities(
'Generate'),
'refresh',
'id="generate_api_key" class="linkobject paddingleft"');
1314 print
'<input type="hidden" name="api_key" value="'.$generated_fake_api_key.
'">';
1318 print
'</table><hr><table class="border centpercent">';
1322 print
'<tr><td class="tdtop titlefieldcreate">'.$form->editfieldkey(
'Address',
'address',
'', $object, 0).
'</td>';
1323 print
'<td><textarea name="address" id="address" class="quatrevingtpercent" rows="3" wrap="soft">';
1325 print
'</textarea></td></tr>';
1328 print
'<tr><td>'.$form->editfieldkey(
'Zip',
'zipcode',
'', $object, 0).
'</td><td>';
1329 print $formcompany->select_ziptown(
$object->zip,
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6);
1333 print
'<tr><td>'.$form->editfieldkey(
'Town',
'town',
'', $object, 0).
'</td><td>';
1334 print $formcompany->select_ziptown(
$object->town,
'town', array(
'zipcode',
'selectcountry_id',
'state_id'));
1338 print
'<tr><td>'.$form->editfieldkey(
'Country',
'selectcountry_id',
'', $object, 0).
'</td><td class="maxwidthonsmartphone">';
1339 print
img_picto(
'',
'country',
'class="pictofixedwidth"');
1340 print $form->select_country((
GETPOST(
'country_id') !=
'' ?
GETPOST(
'country_id') :
$object->country_id),
'country_id');
1342 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1348 print
'<tr><td>'.$form->editfieldkey(
'State',
'state_id',
'', $object, 0).
'</td><td class="maxwidthonsmartphone">';
1349 print
img_picto(
'',
'state',
'class="pictofixedwidth"');
1350 print $formcompany->select_state_ajax(
'country_id',
$object->state_id,
$object->country_id,
'state_id');
1355 print
'<tr><td>'.$langs->trans(
"PhonePro").
'</td>';
1357 print
img_picto(
'',
'object_phoning',
'class="pictofixedwidth"');
1358 if (!empty($ldap_phone)) {
1359 print
'<input type="hidden" name="office_phone" value="'.dol_escape_htmltag($ldap_phone).
'">';
1362 print
'<input class="maxwidth200 widthcentpercentminusx" type="text" name="office_phone" value="'.dol_escape_htmltag(
GETPOST(
'office_phone',
'alphanohtml')).
'">';
1367 print
'<tr><td>'.$langs->trans(
"PhoneMobile").
'</td>';
1369 print
img_picto(
'',
'object_phoning_mobile',
'class="pictofixedwidth"');
1370 if (!empty($ldap_mobile)) {
1371 print
'<input type="hidden" name="user_mobile" value="'.dol_escape_htmltag($ldap_mobile).
'">';
1374 print
'<input class="maxwidth200 widthcentpercentminusx" type="text" name="user_mobile" value="'.dol_escape_htmltag(
GETPOST(
'user_mobile',
'alphanohtml')).
'" spellcheck="false">';
1379 print
'<tr><td>'.$langs->trans(
"Fax").
'</td>';
1381 print
img_picto(
'',
'object_phoning_fax',
'class="pictofixedwidth"');
1382 if (!empty($ldap_fax)) {
1383 print
'<input type="hidden" name="office_fax" value="'.dol_escape_htmltag($ldap_fax).
'">';
1386 print
'<input class="maxwidth200 widthcentpercentminusx" type="text" name="office_fax" value="'.dol_escape_htmltag(
GETPOST(
'office_fax',
'alphanohtml')).
'">';
1391 print
'<tr><td'.(getDolGlobalString(
'USER_MAIL_REQUIRED') ?
' class="fieldrequired"' :
'').
'>'.$langs->trans(
"EMail").
'</td>';
1393 print
img_picto(
'',
'object_email',
'class="pictofixedwidth"');
1394 if (!empty($ldap_mail)) {
1395 print
'<input type="hidden" name="email" value="'.dol_escape_htmltag($ldap_mail).
'">';
1398 print
'<input type="text" name="email" class="maxwidth500 widthcentpercentminusx" value="'.dol_escape_htmltag(
GETPOST(
'email',
'alphanohtml')).
'" spellcheck="false">';
1404 foreach ($socialnetworks as $key => $value) {
1405 if ($value[
'active']) {
1406 print
'<tr><td>'.$langs->trans($value[
'label']).
'</td>';
1408 if (!empty($value[
'icon'])) {
1409 print
'<span class="fab '.$value[
'icon'].
' pictofixedwidth"></span>';
1411 if (!empty($ldap_social[$key])) {
1412 print
'<input type="hidden" name="'.$key.
'" value="'.$ldap_social[$key].
'">';
1413 print $ldap_social[$key];
1415 print
'<input class="maxwidth200 widthcentpercentminusx" type="text" name="'.$key.
'" value="'.
GETPOST($key,
'alphanohtml').
'">';
1420 if (!empty($ldap_social[$key])) {
1421 print
'<input type="hidden" name="'.$key.
'" value="'.$ldap_social[$key].
'">';
1423 print
'<input type="hidden" name="'.$key.
'" value="'.
GETPOST($key,
'alphanohtml').
'">';
1431 print
'<tr><td>'.$langs->trans(
"AccountancyCode").
'</td>';
1433 print
'<input type="text" class="maxwidthonsmartphone" name="accountancy_code" value="'.dol_escape_htmltag(
GETPOST(
'accountancy_code',
'alphanohtml')).
'">';
1439 print
'<tr><td>'.$langs->trans(
"Color").
'</td>';
1441 print $formother->selectColor(GETPOSTISSET(
'color') ?
GETPOST(
'color',
'alphanohtml') :
$object->color,
'color', null, 1, array(),
'hideifnotset');
1446 if (
isModEnabled(
'category') && $user->hasRight(
"categorie",
"read")) {
1447 print
'<tr><td>'.$form->editfieldkey(
'Categories',
'usercats',
'', $object, 0).
'</td><td>';
1448 print $form->selectCategories(Categorie::TYPE_USER,
'usercats', $object);
1454 print
'<tr><td>'.$form->editfieldkey(
'DefaultLang',
'default_lang',
'', $object, 0,
'string',
'', 0, 0,
'id', $langs->trans(
"WarningNotLangOfInterface", $langs->transnoentitiesnoconv(
"UserGUISetup"))).
'</td>';
1455 print
'<td class="maxwidthonsmartphone">'.
"\n";
1456 print
img_picto(
'',
'language',
'class="pictofixedwidth"').$formadmin->select_language(
GETPOST(
'default_lang',
'alpha') ?
GETPOST(
'default_lang',
'alpha') : (
$object->lang ?
$object->lang :
''),
'default_lang', 0, array(), 1, 0, 0,
'maxwidth300 widthcentpercentminusx');
1462 if (
isModEnabled(
'multicompany') && isset($mc) && is_object($mc)) {
1464 if (!method_exists($mc,
'formObjectOptions')) {
1465 if (!
getDolGlobalString(
'MULTICOMPANY_TRANSVERSE_MODE') &&
$conf->entity == 1 && $user->admin && !$user->entity) {
1466 print
"<tr>".
'<td>'.$langs->trans(
"Entity").
'</td>';
1467 print
"<td>".$mc->select_entities(
$conf->entity);
1468 print
"</td></tr>\n";
1470 print
'<input type="hidden" name="entity" value="'.$conf->entity.
'" />';
1476 $parameters = array();
1477 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
1480 print
'<tr><td class="tdtop">'.$langs->trans(
"Signature").
'</td>';
1481 print
'<td class="wordbreak">';
1482 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1484 $doleditor =
new DolEditor(
'signature',
GETPOST(
'signature',
'restricthtml'),
'', 138,
'dolibarr_notes',
'In',
true, $acceptlocallinktomedia, !
getDolGlobalString(
'FCKEDITOR_ENABLE_USERSIGN') ? 0 : 1, ROWS_4,
'90%');
1485 print $doleditor->Create(1);
1489 print
'<tr><td class="tdtop">';
1490 print $langs->trans(
"NotePublic");
1492 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1493 $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%');
1494 $doleditor->Create();
1495 print
"</td></tr>\n";
1498 print
'<tr><td class="tdtop">';
1499 print $langs->trans(
"NotePrivate");
1501 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1502 $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%');
1503 $doleditor->Create();
1504 print
"</td></tr>\n";
1506 print
'</table><hr><table class="border centpercent">';
1513 print
'<tr><td>'.$langs->trans(
"DefaultWarehouse").
'</td><td>';
1514 print $formproduct->selectWarehouses(
$object->fk_warehouse,
'fk_warehouse',
'warehouseopen', 1);
1519 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"PostOrFunction").
'</td>';
1521 print
'<input class="maxwidth200 maxwidth150onsmartphone" type="text" name="job" value="'.dol_escape_htmltag(
GETPOST(
'job',
'alphanohtml')).
'">';
1524 if ((
isModEnabled(
'salaries') && $user->hasRight(
"salaries",
"read") && in_array($id, $childids))
1525 || (
isModEnabled(
'salaries') && $user->hasRight(
"salaries",
"readall"))
1526 || (
isModEnabled(
'hrm') && $user->hasRight(
"hrm",
"employee",
"read"))) {
1527 $langs->load(
"salaries");
1531 $text = $langs->trans(
"THM");
1532 print $form->textwithpicto($text, $langs->trans(
"THMDescription"), 1,
'help',
'classthm');
1535 print
'<input size="8" type="text" name="thm" value="'.dol_escape_htmltag(
GETPOST(
'thm')).
'"> <span class="opacitymedium">'.$langs->getCurrencySymbol().
'</span>';
1541 $text = $langs->trans(
"TJM");
1542 print $form->textwithpicto($text, $langs->trans(
"TJMDescription"), 1,
'help',
'classtjm');
1545 print
'<input size="8" type="text" name="tjm" value="'.dol_escape_htmltag(
GETPOST(
'tjm')).
'"> <span class="opacitymedium">'.$langs->getCurrencySymbol().
'</span>';
1550 print
'<tr><td>'.$langs->trans(
"Salary").
'</td>';
1552 print
img_picto(
'',
'salary',
'class="pictofixedwidth paddingright"').
'<input class="width100" type="text" name="salary" value="'.
dol_escape_htmltag(
GETPOST(
'salary')).
'"> <span class="opacitymedium">'.$langs->getCurrencySymbol().
'</span>';
1558 print
'<tr><td>'.$langs->trans(
"WeeklyHours").
'</td>';
1560 print
'<input size="8" type="text" name="weeklyhours" value="'.dol_escape_htmltag(
GETPOST(
'weeklyhours')).
'">';
1565 print
'<tr><td>'.$langs->trans(
"DateOfEmployment").
'</td>';
1567 print $form->selectDate($dateemployment,
'dateemployment', 0, 0, 1,
'formdateemployment', 1, 1, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"from"));
1571 print $form->selectDate($dateemploymentend,
'dateemploymentend', 0, 0, 1,
'formdateemploymentend', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"));
1576 print
'<tr><td>'.$langs->trans(
"DateOfBirth").
'</td>';
1578 print $form->selectDate($dateofbirth,
'dateofbirth', 0, 0, 1,
'createuser', 1, 0, 0,
'',
'',
'',
'', 1,
'',
'',
'tzserver');
1586 print $form->buttonsSaveCancel(
"CreateUser");
1592 $res =
$object->fetch($id,
'',
'', 1);
1597 $res =
$object->fetch_optionals();
1607 $passDoNotExpire = 0;
1609 $userChangePassNextLogon = 0;
1615 $result = $ldap->connectBind();
1617 $userSearchFilter =
'(' .
getDolGlobalString(
'LDAP_FILTER_CONNECTION').
'('.$ldap->getUserIdentifier().
'='.
$object->login.
'))';
1618 $entries = $ldap->fetch(
$object->login, $userSearchFilter);
1624 if (count($ldap->uacf) > 0) {
1625 foreach ($ldap->uacf as $key => $statut) {
1626 if ($key == 65536) {
1627 $passDoNotExpire = 1;
1628 $statutUACF = $statut;
1633 $statutUACF =
"ACCOUNTDISABLE";
1636 if ($ldap->pwdlastset == 0) {
1637 $userChangePassNextLogon = 1;
1643 if ($mode ==
'employee') {
1644 $title = $langs->trans(
"Employee");
1645 $linkback =
'<a href="'.DOL_URL_ROOT.
'/hrm/employee/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
1647 $title = $langs->trans(
"User");
1650 if ($user->hasRight(
"user",
"user",
"read") || $user->admin) {
1651 $linkback =
'<a href="'.DOL_URL_ROOT.
'/user/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
1658 if ($action ==
'password') {
1659 print $form->formconfirm(
dolBuildUrl($_SERVER[
'PHP_SELF'], [
'id' =>
$object->id]), $langs->trans(
"ReinitPassword"), $langs->trans(
"ConfirmReinitPassword",
$object->login),
"confirm_password",
'', 0, 1);
1663 if ($action ==
'passwordsend') {
1664 print $form->formconfirm(
dolBuildUrl($_SERVER[
'PHP_SELF'], [
'id' =>
$object->id]), $langs->trans(
"SendNewPassword"), $langs->trans(
"ConfirmSendNewPassword",
$object->login),
"confirm_passwordsend",
'', 0, 1);
1668 if ($action ==
'disable') {
1669 print $form->formconfirm(
dolBuildUrl($_SERVER[
'PHP_SELF'], [
'id' =>
$object->id]), $langs->trans(
"DisableAUser"), $langs->trans(
"ConfirmDisableUser",
$object->login),
"confirm_disable",
'', 0, 1);
1673 if ($action ==
'enable') {
1674 print $form->formconfirm(
dolBuildUrl($_SERVER[
'PHP_SELF'], [
'id' =>
$object->id]), $langs->trans(
"EnableAUser"), $langs->trans(
"ConfirmEnableUser",
$object->login),
"confirm_enable",
'', 0, 1);
1678 if ($action ==
'delete') {
1679 print $form->formconfirm(
dolBuildUrl($_SERVER[
'PHP_SELF'], [
'id' =>
$object->id]), $langs->trans(
"DeleteAUser"), $langs->trans(
"ConfirmDeleteUser",
$object->login),
"confirm_delete",
'', 0, 1);
1683 if (($action ==
'clone' && (empty(
$conf->use_javascript_ajax) || !empty(
$conf->dol_use_jmobile)))
1684 || (!empty(
$conf->use_javascript_ajax) && empty(
$conf->dol_use_jmobile))) {
1686 $formquestionclone = array(
1687 'text' => $langs->trans(
"ConfirmClone"),
1688 0 => array(
'type' =>
'text',
'name' =>
'clone_name',
'label' => $langs->trans(
"NewNameUserClone"),
'morecss' =>
'width200'),
1689 1 => array(
'type' =>
'checkbox',
'name' =>
'clone_rights',
'label' => $langs->trans(
"CloneUserRights"),
'value' => 0),
1690 2 => array(
'type' =>
'checkbox',
'name' =>
'clone_categories',
'label' => $langs->trans(
"CloneCategoriesProduct"),
'value' => 0),
1693 $newElement = array(
'type' =>
'text',
'name' =>
'new_email',
'label' => $langs->trans(
"NewEmailUserClone"),
'morecss' =>
'width200');
1694 array_splice($formquestionclone, 2, 0, array($newElement));
1696 print $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmUserClone',
$object->firstname.
' '.
$object->lastname),
'confirm_clone', $formquestionclone,
'yes',
'action-clone', 350, 600);
1701 if ($action !=
'edit') {
1702 print
dol_get_fiche_head($head,
'user', $title, -1,
'user', 0,
'',
'', 0,
'', 1);
1704 $morehtmlref =
'<a href="'.dolBuildUrl(DOL_URL_ROOT.
'/user/vcard.php', [
'id' =>
$object->id,
'output' =>
'file',
'file' =>
dol_sanitizeFileName(
$object->getFullName($langs).
'.vcf')]).
'" class="refid valignmiddle" rel="noopener">';
1705 $morehtmlref .=
img_picto($langs->trans(
"Download").
' '.$langs->trans(
"VCard").
' ('.$langs->trans(
"AddToContacts").
')',
'vcard',
'class="valignmiddle marginleftonly paddingrightonly"');
1706 $morehtmlref .=
'</a>';
1708 $urltovirtualcard =
'/user/virtualcard.php?id='.((int)
$object->id);
1709 $morehtmlref .=
dolButtonToOpenUrlInDialogPopup(
'publicvirtualcard', $langs->transnoentitiesnoconv(
"PublicVirtualCardUrl").
' - '.
$object->getFullName($langs),
img_picto($langs->trans(
"PublicVirtualCardUrl"),
'card',
'class="valignmiddle marginleftonly paddingrightonly"'), $urltovirtualcard,
'',
'refid valignmiddle nohover');
1711 dol_banner_tab($object,
'id', $linkback, $user->hasRight(
"user",
"user",
"read") || $user->admin,
'rowid',
'ref', $morehtmlref);
1713 print
'<div class="fichecenter">';
1714 print
'<div class="fichehalfleft">';
1716 print
'<div class="underbanner clearboth"></div>';
1717 print
'<table class="border tableforfield centpercent">';
1720 print
'<tr><td class="titlefieldmiddle">'.$langs->trans(
"Login").
'</td>';
1721 if (!empty(
$object->ldap_sid) &&
$object->status == User::STATUS_DISABLED) {
1722 print
'<td class="error">';
1723 print $langs->trans(
"LoginAccountDisableInDolibarr");
1729 $addadmin .=
img_picto($langs->trans(
"SuperAdministratorDesc"),
"superadmin",
'class="paddingleft valignmiddle"');
1730 } elseif (!empty(
$object->admin)) {
1731 $addadmin .=
img_picto($langs->trans(
"AdministratorDesc"),
"admin",
'class="paddingleft valignmiddle"');
1733 print showValueWithClipboardCPButton(
$object->login).$addadmin;
1740 $text = $langs->trans(
"Type");
1741 print $form->textwithpicto($text, $langs->trans(
"InternalExternalDesc"));
1743 $type = $langs->trans(
"Internal");
1745 $type = $langs->trans(
"External");
1747 print
'<span class="badgeneutral">';
1750 print
' ('.$langs->trans(
"DomainUser").
')';
1753 print
'</td></tr>'.
"\n";
1756 if (
$object->ldap_sid && is_object($ldap)) {
1757 print
'<tr><td>'.$langs->trans(
"Type").
'</td><td>';
1758 print $langs->trans(
"DomainUser", $ldap->domainFQDN);
1759 print
'</td></tr>'.
"\n";
1763 print
'<tr><td>'.$langs->trans(
"Employee").
'</td><td>';
1765 print
'<input type="checkbox" disabled name="employee" value="1"'.($object->employee ?
' checked="checked"' :
'').
'>';
1769 print
'</td></tr>'.
"\n";
1772 if ($nbofusers > 1) {
1774 print
'<tr><td>'.$langs->trans(
"HierarchicalResponsible").
'</td>';
1776 if (empty(
$object->fk_user)) {
1777 print
'<span class="opacitymedium">'.$langs->trans(
"None").
'</span>';
1781 $huser->fetch(
$object->fk_user);
1782 print $huser->getNomUrl(-1);
1784 print
'<span class="opacitymedium">'.$langs->trans(
"None").
'</span>';
1793 $text = $langs->trans(
"ForceUserExpenseValidator");
1794 print $form->textwithpicto($text, $langs->trans(
"ValidatorIsSupervisorByDefault"), 1,
'help');
1797 if (!empty(
$object->fk_user_expense_validator)) {
1799 $evuser->fetch(
$object->fk_user_expense_validator);
1800 print $evuser->getNomUrl(-1);
1809 $text = $langs->trans(
"ForceUserHolidayValidator");
1810 print $form->textwithpicto($text, $langs->trans(
"ValidatorIsSupervisorByDefault"), 1,
'help');
1813 if (!empty(
$object->fk_user_holiday_validator)) {
1815 $hvuser->fetch(
$object->fk_user_holiday_validator);
1816 print $hvuser->getNomUrl(-1);
1824 print
'<tr><td>'.$langs->trans(
"PostOrFunction").
'</td>';
1825 print
'<td>'.dol_escape_htmltag(
$object->job).
'</td>';
1829 print
'<tr><td>'.$langs->trans(
"WeeklyHours").
'</td>';
1836 if ((empty($user->socid) && in_array($id, $childids))
1837 || (
isModEnabled(
'salaries') && $user->hasRight(
"salaries",
"readall"))
1838 || (
isModEnabled(
'hrm') && $user->hasRight(
"hrm",
"employee",
"read"))) {
1839 $langs->load(
"salaries");
1842 print
'<tr><td>'.$langs->trans(
"Salary").
'</td>';
1844 print(
$object->salary !=
'' ?
img_picto(
'',
'salary',
'class="pictofixedwidth paddingright"').
'<span class="amount">'.
price(
$object->salary, 0, $langs, 1, -1, -1,
$conf->currency) :
'').
'</span>';
1850 $text = $langs->trans(
"THM");
1851 print $form->textwithpicto($text, $langs->trans(
"THMDescription"), 1,
'help',
'classthm');
1854 print(
$object->thm !=
'' ?
'<span class="amount">'.price(
$object->thm, 0, $langs, 1, -1, -1,
$conf->currency).
'</span>' :
'');
1860 $text = $langs->trans(
"TJM");
1861 print $form->textwithpicto($text, $langs->trans(
"TJMDescription"), 1,
'help',
'classtjm');
1864 print(
$object->tjm !=
'' ?
'<span class="amount">'.price(
$object->tjm, 0, $langs, 1, -1, -1,
$conf->currency).
'</span>' :
'');
1870 print
'<tr><td>'.$langs->trans(
"DateOfEmployment").
'</td>';
1872 if (
$object->dateemployment) {
1873 print
'<span class="opacitymedium">'.$langs->trans(
"FromDate").
'</span> ';
1876 if (
$object->dateemploymentend) {
1877 print
'<span class="opacitymedium"> - '.$langs->trans(
"To").
'</span> ';
1884 print
'<tr><td>'.$langs->trans(
"DateOfBirth").
'</td>';
1892 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/entrepot.class.php';
1893 print
'<tr><td>'.$langs->trans(
"DefaultWarehouse").
'</td><td>';
1894 if (
$object->fk_warehouse > 0) {
1896 $warehousestatic->fetch(
$object->fk_warehouse);
1897 print $warehousestatic->getNomUrl(1);
1905 print
'<div class="fichehalfright">';
1907 print
'<div class="underbanner clearboth"></div>';
1909 print
'<table class="border tableforfield centpercent">';
1913 print
'<tr><td class="titlefieldmax45">'.$langs->trans(
"Color").
'</td>';
1915 print $formother->showColor(
$object->color,
'');
1921 if (
isModEnabled(
'category') && $user->hasRight(
"categorie",
"read")) {
1922 print
'<tr><td>'.$langs->trans(
"Categories").
'</td>';
1924 print $form->showCategories(
$object->id, Categorie::TYPE_USER, 1);
1930 $langs->load(
"languages");
1931 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
1933 print $form->textwithpicto($langs->trans(
"DefaultLang"), $langs->trans(
"WarningNotLangOfInterface", $langs->transnoentitiesnoconv(
"UserGUISetup")));
1937 $labellang = (
$object->lang ? $langs->trans(
'Language_'.
$object->lang) :
'');
1943 if (isset(
$conf->file->main_authentication) && preg_match(
'/openid/',
$conf->file->main_authentication) &&
getDolGlobalString(
'MAIN_OPENIDURL_PERUSER')) {
1944 print
'<tr><td>'.$langs->trans(
"OpenIDURL").
'</td>';
1945 print
'<td>'.$object->openid.
'</td>';
1950 if (
isModEnabled(
'multicompany') && isset($mc) && is_object($mc)) {
1952 if (!method_exists($mc,
'formObjectOptions')) {
1954 print
'<tr><td>'.$langs->trans(
"Entity").
'</td><td>';
1956 print $langs->trans(
"AllEntities");
1958 $mc->getInfo(
$object->entity);
1961 print
"</td></tr>\n";
1967 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
1971 print
'<tr><td>'.$langs->trans(
"LinkToCompanyContact").
'</td>';
1976 $societe->fetch(
$object->socid);
1977 if ($societe->id > 0) {
1978 $s .= $societe->getNomUrl(1,
'');
1981 $s .=
'<span class="opacitymedium hideonsmartphone">'.$langs->trans(
"ThisUserIsNot").
'</span>';
1983 if (!empty(
$object->contact_id)) {
1985 $contact->fetch(
$object->contact_id);
1986 if ($contact->id > 0) {
1987 if (
$object->socid > 0 && $s) {
1992 $s .= $contact->getNomUrl(1,
'');
2002 $langs->load(
"members");
2003 print
'<tr><td>'.$langs->trans(
"LinkedToDolibarrMember").
'</td>';
2007 $adh->fetch(
$object->fk_member);
2008 $adh->ref = $adh->getFullname($langs);
2009 print $adh->getNomUrl(-1);
2011 print
'<span class="opacitymedium hideonsmartphone">'.$langs->trans(
"UserNotLinkedToMember").
'</span>';
2018 print
'<tr><td class="tdtop">'.$langs->trans(
'Signature').
'</td><td class="wordbreak">';
2020 print
"</td></tr>\n";
2031 print
'<!-- credential section -->'.
"\n";
2032 print
'<div class="div-table-responsive-no-min">';
2033 print
'<table class="noborder tableforfield centpercent">';
2036 print
'<tr class="liste_titre"><th class="liste_titre" colspan="2">';
2037 print
'<div class="centpercent display-flex">';
2038 print
'<div class="left inline-block">';
2039 print
img_picto(
'',
'security',
'class="paddingleft pictofixedwidth"').$langs->trans(
"SecurityForConnection");
2046 print
'<tr class="nooddeven"><td class="titlefieldmax45 nowraponall">'.$langs->trans(
"RangeOfLoginValidity").
'</td>';
2048 if (
$object->datestartvalidity) {
2049 print
'<span class="opacitymedium">'.$langs->trans(
"FromDate").
'</span> ';
2052 if (
$object->dateendvalidity) {
2053 print
'<span class="opacitymedium"> - '.$langs->trans(
"To").
'</span> ';
2060 if ($_SESSION[
"dol_authmode"] ==
'dolibarr') {
2061 print
'<tr><td class="titlefieldcreate">'.$form->textwithpicto($langs->trans(
"PasswordToChange"), $langs->trans(
"ForcePasswordChange")).
'</td>';
2063 $permissiontoselfeditpassword =
$object->hasRight(
'user',
'self',
'password');
2064 if ($permissiontoselfeditpassword) {
2066 print
'<input type="checkbox" class="colorgrey" disabled name="forcepasswordchange" value="1"'.($object->force_pass_change ?
' checked="checked"' :
'').
'>';
2068 print
'<span class="opacitymedium">'.yn(
$object->force_pass_change).
'</span>';
2071 print
'<span class="opacitymedium">'.yn(
$object->force_pass_change).
'</span>';
2074 print
'<input type="checkbox" name="forcepasswordchange" value="1" disabled class="valignmiddle">';
2075 print $form->textwithpicto(
'<span class="opacitymedium">'.$langs->trans(
"No").
'</span>', $langs->trans(
"UserDoesNotHaveRightsToChangeHisPassword"));
2084 if (preg_match(
'/ldap/', $dolibarr_main_authentication)) {
2085 if (!empty(
$object->ldap_sid)) {
2086 if ($passDoNotExpire) {
2087 $valuetoshow .= ($valuetoshow ? (
' '.$langs->trans(
"or").
' ') :
'').$langs->trans(
"LdapUacf_".$statutUACF);
2088 } elseif ($userChangePassNextLogon) {
2089 $valuetoshow .= ($valuetoshow ? (
' '.$langs->trans(
"or").
' ') :
'').
'<span class="warning">'.$langs->trans(
"UserMustChangePassNextLogon", $ldap->domainFQDN).
'</span>';
2090 } elseif ($userDisabled) {
2091 $valuetoshow .= ($valuetoshow ? (
' '.$langs->trans(
"or").
' ') :
'').
'<span class="warning">'.$langs->trans(
"LdapUacf_".$statutUACF, $ldap->domainFQDN).
'</span>';
2093 $valuetoshow .= ($valuetoshow ? (
' '.$langs->trans(
"or").
' ') :
'').$langs->trans(
"PasswordOfUserInLDAP");
2096 $valuetoshow .= ($valuetoshow ? (
' '.$langs->trans(
"or").
' ') :
'').$langs->trans(
"PasswordOfUserInLDAP");
2099 if (preg_match(
'/http/', $dolibarr_main_authentication)) {
2100 $valuetoshow .= ($valuetoshow ? (
' '.$langs->trans(
"or").
' ') :
'').$langs->trans(
"HTTPBasicPassword");
2104 $parameters = array(
'valuetoshow' => $valuetoshow,
'caneditpasswordandsee' => $permissiontoeditpasswordandsee,
'caneditpasswordandsend' => $permissiontoeditpasswordandsend);
2105 $reshook = $hookmanager->executeHooks(
'printUserPasswordField', $parameters, $object, $action);
2107 $valuetoshow = $hookmanager->resPrint;
2109 $valuetoshow .= $hookmanager->resPrint;
2113 print
'<tr class="nooddeven"><td class="titlefieldmiddle">'.$langs->trans(
"Password").
'</td>';
2114 print
'<td class="wordbreak">';
2121 if (
getDolGlobalString(
'MAIN_SECURITY_ALLOW_TOTP') && $permissiontoeditpasswordandsee) {
2122 print
'<tr class="nooddeven"><td>'.$langs->trans(
"2FA").
'</td>';
2124 print
'<div class="centpercent display-flex">';
2125 print
'<span class="badge badge-info">999</span>';
2126 print
'<div class="left inline-block">';
2127 $s =
'<!-- MAIN_SECURITY_ALLOW_TOTP --><span class="fa fa-pen valignmiddle btnTitle-icon"></span>';
2128 print
dolButtonToOpenUrlInDialogPopup(
'openpopuptoaddcredential', $langs->transnoentitiesnoconv(
"Edit"), $s,
'/user/credentials.php?userid='.$object->id.
'&token='.newToken());
2129 print
'</span></span>';
2134 $tmparrayofauthmode = explode(
',', $dolibarr_main_authentication);
2135 foreach ($tmparrayofauthmode as $tmpauthmode) {
2136 $langs->load(
"oauth");
2138 $tmpauthmode = trim($tmpauthmode);
2139 if (preg_match(
'/oauth/', $tmpauthmode)) {
2140 $nameofservice = preg_replace(
'/oauth/',
'', $tmpauthmode);
2141 print
'<tr class="nooddeven">';
2142 print
'<td class="titlefieldmiddle">'.$langs->trans(
"OAUTH_ID");
2143 print
' '.ucfirst($nameofservice).
' ';
2146 $constoauthlogin =
'OAUTH_'.strtoupper($nameofservice).
'-Login_ID';
2147 print
'<td class="tdoverflowmax200" title="'.dolPrintHTMLForAttribute(
getDolGlobalString($constoauthlogin)).
'">';
2155 if (!empty(
$object->email_oauth2)) {
2156 print
'<tr class="nooddeven"><td class="titlefieldmiddle">'.$langs->trans(
"AlternativeEmailForOAuth2").
'</td>';
2166 if (
isModEnabled(
'api') && ($user->id == $id || $user->admin || $user->hasRight(
"api",
"apikey",
"generate"))) {
2167 print
'<tr class="nooddeven"><td>'.$langs->trans(
"ApiKey").
'</td>';
2170 print
'<div class="centpercent display-flex">';
2171 print
'<span class="badge badge-info">999</span>';
2175 print
'<div class="left inline-block">';
2176 $s =
'<!-- API_IN_TOKEN_TABLE --><span class="fa fa-pen valignmiddle btnTitle-icon"></span>';
2177 print
dolButtonToOpenUrlInDialogPopup(
'openpopuptoaddapitoken', $langs->transnoentitiesnoconv(
"APIKeys"), $s,
'/user/api_token/list.php?id='.$object->id.
'&token='.newToken());
2181 if (!empty(
$object->api_key)) {
2182 print
'<span class="opacitymedium">';
2183 print showValueWithClipboardCPButton(
$object->api_key, 1, $langs->transnoentities(
"Hidden"));
2187 print
' <span class="badge badge-info" title="'.$langs->trans(
"TotalAPICall").
'">';
2197 print
'<tr class="nooddeven"><td>'.$langs->trans(
"LastConnexion").
'</td>';
2199 if (
$object->datepreviouslogin) {
2200 print
dol_print_date(
$object->datepreviouslogin,
"dayhour",
"tzuserrel").
' <span class="opacitymedium">('.$langs->trans(
"Previous").
')</span>, ';
2203 print
dol_print_date(
$object->datelastlogin,
"dayhour",
"tzuserrel").
' <span class="opacitymedium">('.$langs->trans(
"Currently").
')</span>';
2213 $parameters = array(
'caneditpasswordandsee' => $permissiontoeditpasswordandsee,
'caneditpasswordandsend' => $permissiontoeditpasswordandsend);
2214 $reshook = $hookmanager->executeHooks(
'addMoreObjectBlock', $parameters, $object, $action);
2216 print $hookmanager->resPrint;
2222 print
'<div class="clearboth"></div>';
2231 print
'<div class="tabsAction">';
2233 $parameters = array();
2234 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
2235 if (empty($reshook)) {
2239 'class' =>
'classfortooltip'
2243 if (empty($user->socid)) {
2244 $canSendMail =
false;
2246 $langs->load(
"mails");
2247 $canSendMail =
true;
2248 unset($params[
'attr'][
'title']);
2250 $langs->load(
"mails");
2251 $params[
'attr'][
'title'] = $langs->trans(
'NoEMail');
2253 print dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'email',
dolBuildUrl($_SERVER[
'PHP_SELF'], [
'id' =>
$object->id,
'action' =>
'presend',
'mode' =>
'init']) .
'#formmailbeforetitle',
'', $canSendMail, $params);
2258 $params[
'attr'][
'title'] = $langs->trans(
'DisabledInMonoUserMode');
2259 print dolGetButtonAction($langs->trans(
'Modify'),
'',
'default',
dolBuildUrl($_SERVER[
'PHP_SELF']).
'#',
'',
false, $params);
2261 unset($params[
'attr'][
'title']);
2262 print dolGetButtonAction($langs->trans(
'Modify'),
'',
'default',
dolBuildUrl($_SERVER[
'PHP_SELF'], [
'id' =>
$object->id,
'action' =>
'edit'],
true),
'',
true, $params);
2264 } elseif ($permissiontoeditpasswordandsee && !
$object->ldap_sid &&
2266 unset($params[
'attr'][
'title']);
2267 print dolGetButtonAction($langs->trans(
'Modify'),
'',
'default',
dolBuildUrl($_SERVER[
'PHP_SELF'], [
'id' =>
$object->id,
'action' =>
'edit'],
true),
'',
true, $params);
2274 'class' =>
'classfortooltip'
2279 if ((empty(
$object->entity) && $permissiontoclonesuperadmin) || (!empty(
$object->admin) && !empty(
$object->entity) && $permissiontocloneadmin) || ($permissiontocloneuser && empty(
$object->admin) && !empty(
$object->entity))) {
2280 $cloneButtonId =
'';
2283 if (!empty(
$conf->use_javascript_ajax) && empty(
$conf->dol_use_jmobile)) {
2285 $cloneButtonId =
'action-clone';
2287 print dolGetButtonAction($langs->trans(
'ToClone'),
'',
'default', $cloneUserUrl, $cloneButtonId, $user->hasRight(
'user',
'user',
'write'));
2291 if (
$object->status == $object::STATUS_DISABLED) {
2292 $params[
'attr'][
'title'] = $langs->trans(
'UserDisabled');
2293 print dolGetButtonAction($langs->trans(
'ReinitPassword'),
'',
'default',
dolBuildUrl($_SERVER[
'PHP_SELF']).
'#',
'',
false, $params);
2294 } elseif (($user->id != $id && $permissiontoeditpasswordandsee) &&
$object->login && !
$object->ldap_sid &&
2296 unset($params[
'attr'][
'title']);
2297 print dolGetButtonAction($langs->trans(
'ReinitPassword'),
'',
'default', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=password&token='.newToken(),
'',
true, $params);
2300 if (
$object->status == $object::STATUS_DISABLED) {
2301 $params[
'attr'][
'title'] = $langs->trans(
'UserDisabled');
2302 print dolGetButtonAction($langs->trans(
'SendNewPassword'),
'',
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false, $params);
2303 } elseif (($user->id != $id && $permissiontoeditpasswordandsend) &&
$object->login && !
$object->ldap_sid &&
2306 unset($params[
'attr'][
'title']);
2307 print dolGetButtonAction($langs->trans(
'SendNewPassword'),
'',
'default', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=passwordsend&token='.newToken(),
'',
true, $params);
2309 $params[
'attr'][
'title'] = $langs->trans(
'NoEMail');
2310 print dolGetButtonAction($langs->trans(
'SendNewPassword'),
'',
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false, $params);
2315 if ($user->id != $id && $permissiontodisable &&
$object->status == User::STATUS_DISABLED &&
2317 unset($params[
'attr'][
'title']);
2318 print dolGetButtonAction($langs->trans(
'Reactivate'),
'',
'default', $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id .
'&action=enable&token='.newToken(),
'',
true, $params);
2321 if ($user->id != $id && $permissiontodisable &&
$object->status == User::STATUS_ENABLED &&
2323 unset($params[
'attr'][
'title']);
2324 print dolGetButtonAction($langs->trans(
'DisableUser'),
'',
'default', $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id .
'&action=disable&token='.newToken(),
'',
true, $params);
2326 if ($user->id == $id) {
2327 $params[
'attr'][
'title'] = $langs->trans(
'CantDisableYourself');
2328 print dolGetButtonAction($langs->trans(
'DisableUser'),
'',
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false, $params);
2332 if ($user->id != $id && $permissiontodisable &&
2334 if ($user->admin || !
$object->admin) {
2335 unset($params[
'attr'][
'title']);
2336 print dolGetButtonAction($langs->trans(
'DeleteUser'),
'',
'default', $_SERVER[
'PHP_SELF'].
'?action=delete&token='.newToken().
'&id='.
$object->id,
'',
true, $params);
2338 $params[
'attr'][
'title'] = $langs->trans(
'MustBeAdminToDeleteOtherAdmin');
2339 print dolGetButtonAction($langs->trans(
'DeleteUser'),
'',
'default', $_SERVER[
'PHP_SELF'].
'?action=delete&token='.newToken().
'&id='.
$object->id,
'',
false, $params);
2349 if (
GETPOST(
'modelselected')) {
2350 $action =
'presend';
2354 $modelmail =
'user';
2355 $defaulttopic =
'Information';
2356 $diroutput =
$conf->user->dir_output;
2357 $trackid =
'use'.$object->id;
2359 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
2361 if ($action !=
'presend' && $action !=
'send') {
2366 if ($permissiontoreadgroup) {
2367 print
'<!-- Group section -->'.
"\n";
2375 $groupslist = $usergroup->listGroupsForUser(
$object->id,
false);
2377 if (!empty($groupslist)) {
2378 foreach ($groupslist as $groupforuser) {
2379 $exclude[] = $groupforuser->id;
2384 $parameters = array(
'caneditgroup' => $permissiontoeditgroup,
'groupslist' => $groupslist,
'exclude' => $exclude);
2385 $reshook = $hookmanager->executeHooks(
'formAddUserToGroup', $parameters, $object, $action);
2386 print $hookmanager->resPrint;
2388 if (empty($reshook)) {
2389 if ($permissiontoeditgroup) {
2390 print
'<form action="'.$_SERVER[
'PHP_SELF'].
'?id='.
$id.
'" method="POST">'.
"\n";
2391 print
'<input type="hidden" name="token" value="'.newToken().
'" />';
2392 print
'<input type="hidden" name="action" value="addgroup" />';
2393 print
'<input type="hidden" name="page_y" value="" />';
2396 print
'<!-- List of groups of the user -->'.
"\n";
2397 print
'<table class="noborder centpercent">'.
"\n";
2398 print
'<tr class="liste_titre">';
2400 print
'<th class="liste_titre right" colspan="2">';
2401 if ($permissiontoeditgroup) {
2402 print $form->select_dolgroups(0,
'group', 1, $exclude, 0,
'', array(), (
string)
$object->entity,
false,
'maxwidth150');
2404 print
'<input type="hidden" name="entity" value="'.$conf->entity.
'" />';
2405 print
'<input type="submit" class="button buttongen button-add reposition" value="'.$langs->trans(
"Add").
'" />';
2407 print
'</th></tr>'.
"\n";
2410 if (!empty($groupslist)) {
2411 foreach ($groupslist as $group) {
2412 print
'<tr class="oddeven">';
2413 print
'<td class="tdoverflowmax200">';
2414 if ($permissiontoeditgroup) {
2415 print $group->getNomUrl(1);
2417 print
img_object($langs->trans(
"ShowGroup"),
"group").
' '.$group->name;
2420 print
'<td class="right">';
2421 if ($permissiontoeditgroup) {
2422 print
'<a class="reposition" href="'.dolBuildUrl($_SERVER[
'PHP_SELF'], [
'id' =>
$object->id,
'action' =>
'removegroup',
'group' => $group->id],
true).
'">';
2423 print
img_picto($langs->trans(
"RemoveFromGroup"),
'unlink');
2428 print
"</td></tr>\n";
2431 print
'<tr class="oddeven"><td colspan="2"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
2436 if ($permissiontoeditgroup) {
2448 if ($action ==
'edit' && ($permissiontoedit || $permissiontoeditpasswordandsee)) {
2449 print
'<form action="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'" method="POST" name="updateuser" enctype="multipart/form-data">';
2450 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2451 print
'<input type="hidden" name="action" value="update">';
2452 print
'<input type="hidden" name="entity" value="'.$object->entity.
'">';
2456 print
'<table class="border centpercent">';
2460 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Ref").
'</td>';
2469 print
'<td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Lastname").
'</td>';
2471 if ($permissiontoedit && !
$object->ldap_sid) {
2472 print
'<input class="minwidth100" type="text" class="flat" name="lastname" value="'.$object->lastname.
'">';
2474 print
'<input type="hidden" name="lastname" value="'.$object->lastname.
'">';
2481 print
'<tr><td>'.$langs->trans(
"Firstname").
'</td>';
2483 if ($permissiontoedit && !
$object->ldap_sid) {
2484 print
'<input class="minwidth100" type="text" class="flat" name="firstname" value="'.$object->firstname.
'">';
2486 print
'<input type="hidden" name="firstname" value="'.$object->firstname.
'">';
2492 print
"<tr>".
'<td><span class="fieldrequired">'.$langs->trans(
"Login").
'</span></td>';
2494 if ($user->admin && !
$object->ldap_sid) {
2495 print
'<input maxlength="50" type="text" class="flat" name="login" value="'.$object->login.
'" spellcheck="false">';
2497 print
'<input type="hidden" name="login" value="'.$object->login.
'">';
2504 print
'<tr><td>'.$langs->trans(
"ExternalUser").
' ?</td>';
2506 if ($user->id ==
$object->id || !$user->admin) {
2508 $type = $langs->trans(
"Internal");
2510 $type = $langs->trans(
"External");
2513 print $form->textwithpicto($type, $langs->trans(
"InternalExternalDesc"));
2515 print
' ('.$langs->trans(
"DomainUser").
')';
2524 $eventsCompanyContact = array();
2525 $eventsCompanyContact[] = array(
'method' =>
'getContacts',
'url' =>
dol_buildpath(
'/core/ajax/contacts.php?showempty=1&token='.currentToken(), 1),
'htmlname' =>
'contactid',
'params' => array(
'add-customer-contact' =>
'disabled'));
2527 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
2528 print $form->select_company(
$object->socid,
'socid',
'',
' ', 0, 0, $eventsCompanyContact, 0,
'widthcentpercentminusxx maxwidth300');
2529 print
'<span class="clearbothonsmartphone"></span>';
2530 print
img_picto(
'',
'contact',
'class="pictofixedwidth"');
2531 print $form->select_contact(0, 0,
'contactid', 1,
'',
'', 1,
'minwidth100imp widthcentpercentminusxx maxwidth300',
true, 1);
2533 print
' ('.$langs->trans(
"DomainUser").
')';
2536 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
2537 print $form->select_company(
$object->socid,
'socid',
'',
' ', 0, 0, $eventsCompanyContact, 0,
'widthcentpercentminusxx maxwidth300');
2538 print
'<span class="clearbothonsmartphone"></span>';
2539 print
img_picto(
'',
'contact',
'class="pictofixedwidth"');
2540 print $form->select_contact(0,
$object->contact_id,
'contactid', 1,
'',
'', 1,
'minwidth100imp widthcentpercentminusxx maxwidth300',
true, 1);
2542 print
' ('.$langs->trans(
"DomainUser").
')';
2545 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
2546 print $form->select_company(0,
'socid',
'',
' ', 0, 0, $eventsCompanyContact, 0,
'widthcentpercentminusxx maxwidth300');
2547 print
'<span class="clearbothonsmartphone"></span>';
2548 print
img_picto(
'',
'contact',
'class="pictofixedwidth"');
2549 print $form->select_contact(0,
$object->contact_id,
'contactid', 1,
'',
'', 1,
'minwidth100imp widthcentpercentminusxx maxwidth300',
true, 1);
2551 print
' ('.$langs->trans(
"DomainUser").
')';
2554 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
2555 print $form->select_company(0,
'socid',
'',
' ', 0, 0, $eventsCompanyContact, 0,
'widthcentpercentminusxx maxwidth300');
2556 print
'<span class="clearbothonsmartphone"></span>';
2557 print
img_picto(
'',
'contact',
'class="pictofixedwidth"');
2558 print $form->select_contact(0, 0,
'contactid', 1,
'',
'', 1,
'minwidth100imp widthcentpercentminusxx maxwidth300',
true, 1);
2564 print
'<tr><td>'.$form->textwithpicto($langs->trans(
"Administrator"), $langs->trans(
"AdministratorDesc")).
'</td>';
2566 $langs->load(
"admin");
2568 print
'<input type="hidden" name="admin" value="'.$object->admin.
'">'.
yn(
$object->admin);
2569 print
' <span class="opacitymedium">('.$langs->trans(
"ExternalUser").
')</span>';
2573 $nbAdmin = $user->getNbOfUsers(
'active',
'', 1);
2574 $nbSuperAdmin = $user->getNbOfUsers(
'active',
'superadmin', 1);
2581 || (
isModEnabled(
'multicompany') && ((
$object->entity > 0 || ($user->entity == 0 &&
$object->entity == 0)) || $nbSuperAdmin > 1))
2584 print $form->selectyesno(
'admin',
$object->admin, 1,
false, 0, 1);
2587 if (
$conf->use_javascript_ajax) {
2588 print
'<script type="text/javascript">
2590 var admin = $("select[name=admin]").val();
2592 $("input[name=superadmin]")
2593 .prop("disabled", true)
2594 .prop("checked", false);
2596 if ($("input[name=superadmin]").is(":checked")) {
2597 $("select[name=entity]")
2598 .prop("disabled", true);
2600 $("select[name=admin]").change(function() {
2601 if ( $(this).val() == 0 ) {
2602 $("input[name=superadmin]")
2603 .prop("disabled", true)
2604 .prop("checked", false);
2605 $("select[name=entity]")
2606 .prop("disabled", false);
2608 $("input[name=superadmin]")
2609 .prop("disabled", false);
2612 $("input[name=superadmin]").change(function() {
2613 if ( $(this).is(":checked")) {
2614 $("select[name=entity]")
2615 .prop("disabled", true);
2617 $("select[name=entity]")
2618 .prop("disabled", false);
2625 $checked = ((
$object->admin && !
$object->entity) ?
' checked' :
'');
2626 print
'<input type="checkbox" name="superadmin" id="superadmin" value="1"'.$checked.
' /> <label for="superadmin">'.$langs->trans(
"SuperAdministrator").
'</span>';
2630 print
'<input type="hidden" name="admin" value="'.$object->admin.
'">';
2631 print
'<input type="hidden" name="superadmin" value="'.(empty(
$object->entity) ? 1 : 0).
'">';
2633 print $form->textwithpicto($yn, $langs->trans(
"DontDowngradeSuperAdmin"), 1,
'warning');
2643 print
'<tr><td class="titlefieldcreate"><label for="civility_code">'.$langs->trans(
"UserTitle").
'</label></td><td>';
2644 if ($permissiontoedit && !
$object->ldap_sid) {
2645 print $formcompany->select_civility(GETPOSTISSET(
"civility_code") ?
GETPOST(
"civility_code",
'aZ09') :
$object->civility_code,
'civility_code');
2646 } elseif (
$object->civility_code) {
2647 print $langs->trans(
"Civility".
$object->civility_code);
2653 print
'<tr><td>'.$langs->trans(
"Gender").
'</td>';
2655 $arraygender = array(
'man' => $langs->trans(
"Genderman"),
'woman' => $langs->trans(
"Genderwoman"),
'other' => $langs->trans(
"Genderother"));
2656 if ($permissiontoedit) {
2657 print $form->selectarray(
'gender', $arraygender, GETPOSTISSET(
'gender') ?
GETPOST(
'gender') :
$object->gender, 1);
2659 print $arraygender[
$object->gender];
2665 print
'<td>'.$form->editfieldkey(
'Employee',
'employee',
'', $object, 0).
'</td><td>';
2666 if ($permissiontoedit) {
2667 print
'<input type="checkbox" name="employee" value="1"'.($object->employee ?
' checked="checked"' :
'').
'>';
2670 print
'<input type="checkbox" name="employee" disabled value="1"'.($object->employee ?
' checked="checked"' :
'').
'>';
2679 if ($nbofusers > 1) {
2681 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"HierarchicalResponsible").
'</td>';
2683 if ($permissiontoedit) {
2684 print
img_picto(
'',
'user',
'class="pictofixedwidth"').$form->select_dolusers(GETPOSTISSET(
'fk_user') ?
GETPOSTINT(
'fk_user') :
$object->fk_user,
'fk_user', 1, array(
$object->id), 0,
'',
'', (
string)
$object->entity, 0, 0,
'', 0,
'',
'widthcentpercentminusx maxwidth300');
2686 print
'<input type="hidden" name="fk_user" value="'.$object->fk_user.
'">';
2688 $huser->fetch(
$object->fk_user);
2689 print $huser->getNomUrl(-1);
2696 print
'<tr><td class="titlefieldcreate">';
2697 $text = $langs->trans(
"ForceUserExpenseValidator");
2698 print $form->textwithpicto($text, $langs->trans(
"ValidatorIsSupervisorByDefault"), 1,
'help');
2701 if ($permissiontoedit) {
2702 print
img_picto(
'',
'user',
'class="pictofixedwidth"').$form->select_dolusers(
$object->fk_user_expense_validator,
'fk_user_expense_validator', 1, array(
$object->id), 0,
'',
'', (
string)
$object->entity, 0, 0,
'', 0,
'',
'widthcentpercentminusx maxwidth300');
2704 print
'<input type="hidden" name="fk_user_expense_validator" value="'.$object->fk_user_expense_validator.
'">';
2706 $evuser->fetch(
$object->fk_user_expense_validator);
2707 print $evuser->getNomUrl(-1);
2715 print
'<tr><td class="titlefieldcreate">';
2716 $text = $langs->trans(
"ForceUserHolidayValidator");
2717 print $form->textwithpicto($text, $langs->trans(
"ValidatorIsSupervisorByDefault"), 1,
'help');
2720 if ($permissiontoedit) {
2721 print
img_picto(
'',
'user',
'class="pictofixedwidth"').$form->select_dolusers(
$object->fk_user_holiday_validator,
'fk_user_holiday_validator', 1, array(
$object->id), 0,
'',
'', (
string)
$object->entity, 0, 0,
'', 0,
'',
'widthcentpercentminusx maxwidth300');
2723 print
'<input type="hidden" name="fk_user_holiday_validator" value="'.$object->fk_user_holiday_validator.
'">';
2725 $hvuser->fetch(
$object->fk_user_holiday_validator);
2726 print $hvuser->getNomUrl(-1);
2737 print
'<table class="border centpercent">';
2740 print
'<tr><td>'.$langs->trans(
"RangeOfLoginValidity").
'</td>';
2742 if ($permissiontoedit) {
2743 print $form->selectDate($datestartvalidity ? $datestartvalidity :
$object->datestartvalidity,
'datestartvalidity', 0, 0, 1,
'formdatestartvalidity', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"from"));
2749 if ($permissiontoedit) {
2750 print $form->selectDate($dateendvalidity ? $dateendvalidity :
$object->dateendvalidity,
'dateendvalidity', 0, 0, 1,
'formdateendvalidity', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"));
2759 if ($_SESSION[
"dol_authmode"] ==
'dolibarr') {
2761 print
'<td>'.$form->editfieldkey($form->textwithpicto($langs->trans(
"PasswordToChange"), $langs->trans(
"ForcePasswordChange")),
'forcepasswordchange',
'', $object, 0).
'</td><td>';
2762 $permissiontoselfeditpassword =
$object->hasRight(
'user',
'self',
'password');
2763 if ($permissiontoselfeditpassword) {
2764 if ($permissiontoedit) {
2765 print
'<input type="checkbox" name="forcepasswordchange" id="forcepasswordchange" value="1"'.($object->force_pass_change ?
' checked="checked"' :
'').
'>';
2766 print
'<label class="opacitylow" for="forcepasswordchange">'.$langs->trans(
"AtNextLogin").
'</label>';
2768 print
'<input type="checkbox" name="forcepasswordchange" class="colorgrey" disabled value="1"'.($object->force_pass_change ?
' checked="checked"' :
'').
'>';
2769 print $langs->trans(
"AtNextLogin");
2772 print
'<input type="checkbox" name="forcepasswordchange" value="1" class="colorgrey" disabled>';
2773 print
'<span class="opacitymedium">'.$langs->trans(
"UserDoesNotHaveRightsToChangeHisPassword").
'</span>';
2780 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Password").
'</td>';
2783 if (preg_match(
'/ldap/', $dolibarr_main_authentication)) {
2784 $valuetoshow .= ($valuetoshow ? (
' '.$langs->trans(
"or").
' ') :
'').$langs->trans(
"PasswordOfUserInLDAP");
2786 if (preg_match(
'/http/', $dolibarr_main_authentication)) {
2787 $valuetoshow .= ($valuetoshow ? (
' '.$langs->trans(
"or").
' ') :
'').$form->textwithpicto((
string) $text, $langs->trans(
"DolibarrInHttpAuthenticationSoPasswordUseless", (
string) $dolibarr_main_authentication), 1,
'warning');
2789 if (preg_match(
'/dolibarr/', $dolibarr_main_authentication) || preg_match(
'/forceuser/', $dolibarr_main_authentication)) {
2790 if ($permissiontoeditpasswordandsee) {
2791 $valuetoshow .= ($valuetoshow ? (
' '.$langs->trans(
"or").
' ') :
'').
'<input maxlength="128" type="password" class="minwidth300 maxwidth400 widthcentpercentminusx" id="password" name="password" value="'.
dol_escape_htmltag(
$object->pass).
'" autocomplete="new-password" spellcheck="false">';
2792 if (!empty(
$conf->use_javascript_ajax)) {
2793 $valuetoshow .=
img_picto((
getDolGlobalString(
'USER_PASSWORD_GENERATED') ===
'none' ? $langs->transnoentities(
'NoPasswordGenerationRuleConfigured') : $langs->transnoentities(
'Generate')),
'refresh',
'id="generate_password" class="paddingleft'.(
getDolGlobalString(
'USER_PASSWORD_GENERATED') ===
'none' ?
' opacitymedium' :
' linkobject').
'"');
2796 $valuetoshow .= ($valuetoshow ? (
' '.$langs->trans(
"or").
' ') :
'').preg_replace(
'/./i',
'*',
$object->pass);
2800 $parameters = array(
'valuetoshow' => $valuetoshow,
'caneditpasswordandsee' => $permissiontoeditpasswordandsee,
'caneditpasswordandsend' => $permissiontoeditpasswordandsend);
2801 $reshook = $hookmanager->executeHooks(
'printUserPasswordField', $parameters, $object, $action);
2803 $valuetoshow = $hookmanager->resPrint;
2805 $valuetoshow .= $hookmanager->resPrint;
2809 print
"</td></tr>\n";
2814 print
'<tr><td>'.$langs->trans(
"ApiKey").
'</td>';
2816 if ($permissiontoeditpasswordandsee || $user->hasRight(
"api",
"apikey",
"generate")) {
2817 print
'<input class="minwidth300 maxwidth400 widthcentpercentminusx" minlength="12" maxlength="128" type="text" id="api_key" name="api_key" value="'.$object->api_key.
'" autocomplete="off" spellcheck="false">';
2818 if (!empty(
$conf->use_javascript_ajax)) {
2819 print
img_picto($langs->transnoentities(
'Generate'),
'refresh',
'id="generate_api_key" class="linkobject paddingleft"');
2827 if (isset(
$conf->file->main_authentication) && preg_match(
'/openid/',
$conf->file->main_authentication) &&
getDolGlobalString(
'MAIN_OPENIDURL_PERUSER')) {
2828 print
"<tr>".
'<td>'.$langs->trans(
"OpenIDURL").
'</td>';
2830 if ($permissiontoedit) {
2831 print
'<input class="minwidth100" type="url" name="openid" class="flat" value="'.$object->openid.
'">';
2833 print
'<input type="hidden" name="openid" value="'.$object->openid.
'">';
2839 print
'</table><hr><table class="border centpercent">';
2843 print
'<tr><td class="tdtop titlefieldcreate">'.$form->editfieldkey(
'Address',
'address',
'', $object, 0).
'</td>';
2845 if ($permissiontoedit) {
2846 print
'<textarea name="address" id="address" class="quatrevingtpercent" rows="3" wrap="soft">';
2849 if ($permissiontoedit) {
2850 print
'</textarea>';
2855 print
'<tr><td>'.$form->editfieldkey(
'Zip',
'zipcode',
'', $object, 0).
'</td><td>';
2856 if ($permissiontoedit) {
2857 print $formcompany->select_ziptown((GETPOSTISSET(
'zipcode') ?
GETPOST(
'zipcode') :
$object->zip),
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6);
2864 print
'<tr><td>'.$form->editfieldkey(
'Town',
'town',
'', $object, 0).
'</td><td>';
2865 if ($permissiontoedit) {
2866 print $formcompany->select_ziptown((GETPOSTISSET(
'town') ?
GETPOST(
'town') :
$object->town),
'town', array(
'zipcode',
'selectcountry_id',
'state_id'));
2873 print
'<tr><td>'.$form->editfieldkey(
'Country',
'selectcountry_id',
'', $object, 0).
'</td><td>';
2874 print
img_picto(
'',
'country',
'class="pictofixedwidth"');
2875 if ($permissiontoedit) {
2876 print $form->select_country((
GETPOST(
'country_id') !=
'' ?
GETPOST(
'country_id') :
$object->country_id),
'country_id');
2878 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
2882 print $countrylabel;
2888 print
'<tr><td class="tdoverflow">'.$form->editfieldkey(
'State',
'state_id',
'', $object, 0).
'</td><td>';
2889 if ($permissiontoedit) {
2890 print
img_picto(
'',
'state',
'class="pictofixedwidth"');
2891 print $formcompany->select_state_ajax(
'country_id',
$object->state_id,
$object->country_id,
'state_id');
2899 print
"<tr>".
'<td>'.$langs->trans(
"PhonePro").
'</td>';
2901 print
img_picto(
'',
'phoning',
'class="pictofixedwidth"');
2902 if ($permissiontoedit && empty(
$object->ldap_sid)) {
2903 print
'<input type="text" name="office_phone" class="flat maxwidth200 widthcentpercentminusx" value="'.$object->office_phone.
'">';
2905 print
'<input type="hidden" name="office_phone" value="'.$object->office_phone.
'">';
2911 print
"<tr>".
'<td>'.$langs->trans(
"PhoneMobile").
'</td>';
2913 print
img_picto(
'',
'phoning_mobile',
'class="pictofixedwidth"');
2914 if ($permissiontoedit && empty(
$object->ldap_sid)) {
2915 print
'<input type="text" name="user_mobile" class="flat maxwidth200 widthcentpercentminusx" value="'.$object->user_mobile.
'" spellcheck="false">';
2917 print
'<input type="hidden" name="user_mobile" value="'.$object->user_mobile.
'">';
2923 print
"<tr>".
'<td>'.$langs->trans(
"Fax").
'</td>';
2925 print
img_picto(
'',
'phoning_fax',
'class="pictofixedwidth"');
2926 if ($permissiontoedit && empty(
$object->ldap_sid)) {
2927 print
'<input type="text" name="office_fax" class="flat maxwidth200 widthcentpercentminusx" value="'.$object->office_fax.
'">';
2929 print
'<input type="hidden" name="office_fax" value="'.$object->office_fax.
'">';
2935 print
"<tr>".
'<td'.(
getDolGlobalString(
'USER_MAIL_REQUIRED') ?
' class="fieldrequired"' :
'').
'>'.$langs->trans(
"EMail").
'</td>';
2937 print
img_picto(
'',
'object_email',
'class="pictofixedwidth"');
2938 if ($permissiontoedit && empty(
$object->ldap_sid)) {
2939 print
'<input class="minwidth100 maxwidth500 widthcentpercentminusx" type="text" name="email" class="flat" value="'.$object->email.
'">';
2941 print
'<input type="hidden" name="email" value="'.$object->email.
'">';
2947 foreach ($socialnetworks as $key => $value) {
2948 if ($value[
'active']) {
2949 print
'<tr><td>'.$langs->trans($value[
'label']).
'</td>';
2951 if (!empty($value[
'icon'])) {
2952 print
'<span class="fab '.$value[
'icon'].
' pictofixedwidth"></span>';
2954 if ($permissiontoedit && empty(
$object->ldap_sid)) {
2955 print
'<input type="text" name="'.$key.
'" class="flat maxwidth200 widthcentpercentminusx" value="'.(isset(
$object->socialnetworks[$key]) ?
$object->socialnetworks[$key] :
'').
'">';
2957 print
'<input type="hidden" name="'.$key.
'" value="'.
$object->socialnetworks[$key].
'">';
2958 print
$object->socialnetworks[$key];
2963 print
'<input type="hidden" name="'.$key.
'" value="'.(isset(
$object->socialnetworks[$key]) ?
$object->socialnetworks[$key] :
'').
'">';
2968 print
'</table><hr><table class="border centpercent">';
2972 print
'<tr><td class="titlefield">'.$langs->trans(
"DefaultWarehouse").
'</td><td>';
2973 print $formproduct->selectWarehouses(
$object->fk_warehouse,
'fk_warehouse',
'warehouseopen', 1);
2974 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>';
2981 print
'<td class="titlefieldcreate">'.$langs->trans(
"AccountancyCode").
'</td>';
2983 if ($permissiontoedit) {
2984 print
'<input type="text" class="flat maxwidth300" name="accountancy_code" value="'.$object->accountancy_code.
'">';
2986 print
'<input type="hidden" name="accountancy_code" value="'.$object->accountancy_code.
'">';
2987 print
$object->accountancy_code;
2995 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ColorUser").
'</td>';
2997 if ($permissiontoedit) {
2998 print $formother->selectColor(GETPOSTISSET(
'color') ?
GETPOST(
'color',
'alphanohtml') :
$object->color,
'color', null, 1, array(),
'hideifnotset');
3000 print $formother->showColor(
$object->color,
'');
3007 print
'<td class="titlefieldcreate">'.$langs->trans(
"Photo").
'</td>';
3009 print $form->showphoto(
'userphoto', $object, 60, 0, (
int) $permissiontoedit,
'photowithmargin',
'small', 1, 0,
'user', 1);
3014 if (
isModEnabled(
'category') && $user->hasRight(
"categorie",
"read")) {
3015 print
'<tr><td>'.$form->editfieldkey(
'Categories',
'usercats',
'', $object, 0).
'</td>';
3017 if ($permissiontoedit) {
3018 print $form->selectCategories(Categorie::TYPE_USER,
'usercats', $object);
3020 print $form->showCategories(
$object->id, Categorie::TYPE_USER, 1);
3027 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";
3028 print
img_picto(
'',
'language',
'class="pictofixedwidth"').$formadmin->select_language(
$object->lang,
'default_lang', 0, array(),
'1', 0, 0,
'widthcentpercentminusx maxwidth300');
3034 print
'<tr><td>'.$langs->trans(
"Status").
'</td>';
3036 print
$object->getLibStatut(4);
3064 $langs->load(
"members");
3065 print
'<tr><td>'.$langs->trans(
"LinkedToDolibarrMember").
'</td>';
3069 $adh->fetch(
$object->fk_member);
3070 $adh->ref = $adh->login;
3071 print $adh->getNomUrl(1);
3073 print
'<span class="opacitymedium hideonsmartphone">'.$langs->trans(
"UserNotLinkedToMember").
'</span>';
3081 if (
isModEnabled(
'multicompany') && isset($mc) && is_object($mc)) {
3083 if (!method_exists($mc,
'formObjectOptions')) {
3084 if (empty(
$conf->multicompany->transverse_mode) &&
$conf->entity == 1 && $user->admin && !$user->entity) {
3085 print
"<tr>".
'<td>'.$langs->trans(
"Entity").
'</td>';
3086 print
"<td>".$mc->select_entities(
$object->entity,
'entity',
'',
false,
true,
false,
false,
true);
3087 print
"</td></tr>\n";
3089 print
'<input type="hidden" name="entity" value="'.$conf->entity.
'" />';
3095 $parameters = array(
'colspan' =>
' colspan="2"');
3097 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
3098 print $hookmanager->resPrint;
3099 if (empty($reshook)) {
3100 if ($permissiontoedit) {
3101 print
$object->showOptionals($extrafields,
'edit');
3103 print
$object->showOptionals($extrafields,
'view');
3108 print
'<tr><td class="tdtop">'.$langs->trans(
"Signature").
'</td>';
3110 if ($permissiontoedit) {
3111 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
3113 $doleditor =
new DolEditor(
'signature',
$object->signature,
'', 138,
'dolibarr_notes',
'In',
false, $acceptlocallinktomedia, !
getDolGlobalString(
'FCKEDITOR_ENABLE_USERSIGN') ? 0 : 1, ROWS_4,
'90%');
3114 print $doleditor->Create(1);
3126 print
'<table class="border centpercent">';
3132 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"PostOrFunction").
'</td>';
3134 if ($permissiontoedit) {
3135 print
'<input type="text" class="minwidth300 maxwidth500" name="job" value="'.dol_escape_htmltag(
$object->job).
'">';
3137 print
'<input type="hidden" name="job" value="'.dol_escape_htmltag(
$object->job).
'">';
3143 print
'<tr><td>'.$langs->trans(
"WeeklyHours").
'</td>';
3145 if ($permissiontoedit) {
3146 print
'<input size="8" type="text" name="weeklyhours" value="'.price2num(
GETPOST(
'weeklyhours') ?
GETPOST(
'weeklyhours') :
$object->weeklyhours).
'">';
3154 if ((empty($user->socid) && in_array($id, $childids))
3155 || (
isModEnabled(
'salaries') && $user->hasRight(
"salaries",
"readall"))
3156 || (
isModEnabled(
'hrm') && $user->hasRight(
"hrm",
"employee",
"read"))) {
3157 $langs->load(
"salaries");
3160 print
'<tr><td>'.$langs->trans(
"Salary").
'</td>';
3162 print
img_picto(
'',
'salary',
'class="pictofixedwidth paddingright"').
'<input size="8" type="text" name="salary" value="'.
price2num(
GETPOST(
'salary') ?
GETPOST(
'salary') :
$object->salary).
'">';
3163 print
' <span class="opacitymedium">'.$langs->getCurrencySymbol().
'</span>';
3169 $text = $langs->trans(
"THM");
3170 print $form->textwithpicto($text, $langs->trans(
"THMDescription"), 1,
'help',
'classthm');
3173 if ($permissiontoedit) {
3174 print
'<input size="8" type="text" name="thm" value="'.price2num(
GETPOST(
'thm') ?
GETPOST(
'thm') :
$object->thm).
'">';
3175 print
' <span class="opacitymedium">'.$langs->getCurrencySymbol().
'</span>';
3184 $text = $langs->trans(
"TJM");
3185 print $form->textwithpicto($text, $langs->trans(
"TJMDescription"), 1,
'help',
'classthm');
3188 if ($permissiontoedit) {
3189 print
'<input size="8" type="text" name="tjm" value="'.price2num(
GETPOST(
'tjm') ?
GETPOST(
'tjm') :
$object->tjm).
'">';
3190 print
' <span class="opacitymedium">'.$langs->getCurrencySymbol().
'</span>';
3199 print
'<tr><td>'.$langs->trans(
"DateEmployment").
'</td>';
3201 if ($permissiontoedit) {
3202 print $form->selectDate($dateemployment ? $dateemployment :
$object->dateemployment,
'dateemployment', 0, 0, 1,
'formdateemployment', 1, 1, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"from"));
3207 if ($dateemployment && $dateemploymentend) {
3211 if ($permissiontoedit) {
3212 print $form->selectDate($dateemploymentend ? $dateemploymentend :
$object->dateemploymentend,
'dateemploymentend', 0, 0, 1,
'formdateemploymentend', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"));
3220 print
'<tr><td>'.$langs->trans(
"DateOfBirth").
'</td>';
3222 if ($permissiontoedit) {
3223 echo $form->selectDate($dateofbirth ? $dateofbirth :
$object->birth,
'dateofbirth', 0, 0, 1,
'updateuser', 1, 0, 0,
'',
'',
'',
'', 1,
'',
'',
'tzserver');
3234 print
'<div class="center">';
3235 print
'<input value="'.$langs->trans(
"Save").
'" class="button button-save" type="submit" name="save">';
3236 print
' ';
3237 print
'<input value="'.$langs->trans(
"Cancel").
'" class="button button-cancel" type="submit" name="cancel">';
3243 if ($action !=
'edit' && $action !=
'presend') {
3244 print
'<div class="fichecenter"><div class="fichehalfleft">';
3249 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
3250 $genallowed = $user->hasRight(
"user",
"user",
"read");
3251 $delallowed = $user->hasRight(
"user",
"user",
"write");
3256 $societe->fetch(
$object->socid);
3261 print $formfile->showdocuments(
'user', $filename, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 0, 0, 0, 28, 0,
'',
'',
'', !is_object($societe) || empty($societe->default_lang) ?
'' : $societe->default_lang);
3262 $somethingshown = $formfile->numoffiles;
3266 $morehtmlcenter =
'<div class="nowraponall">';
3267 $morehtmlcenter .= dolGetButtonTitle($langs->trans(
'FullConversation'),
'',
'fa fa-comments imgforviewmode', DOL_URL_ROOT.
'/user/messaging.php?id='.
$object->id);
3268 $morehtmlcenter .= dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode', DOL_URL_ROOT.
'/user/agenda.php?id='.
$object->id);
3269 $morehtmlcenter .=
'</div>';
3271 print
'</div><div class="fichehalfright">';
3274 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
3276 $somethingshown = $formactions->showactions($object,
'user', $socid, 1,
'listactions', $MAXEVENT,
'', $morehtmlcenter,
$object->id);
3278 print
'</div></div>';
3288include_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='')
Convert a html select field into an ajax combobox.
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage members of a foundation.
Class to manage a WYSIWYG editor.
Class to manage warehouses.
Class to manage LDAP features.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage user groups.
Class to manage Dolibarr users.
getCountry($searchkey, $withcode='', $dbtouse=null, $outputlangs=null, $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
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.
addFileIntoDatabaseIndex($dir, $file, $fullpathorig='', $mode='uploaded', $setsharekey=0, $object=null, $forceFullTextIndexation='')
Add a file into database index.
dol_delete_dir_recursive($dir, $count=0, $nophperrors=0, $onlysub=0, &$countdeleted=0, $indexdatabase=1, $nolog=0, $level=0)
Remove a directory $dir and its subdirectories (or only files and subdirectories)
dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disablevirusscan=0, $uploaderrorcode=0, $nohook=0, $keyforsourcefile='addedfile', $upload_dir='', $mode=0)
Check validity of a file upload from an GUI page, and move it to its final destination.
deleteFilesIntoDatabaseIndex($dir, $file, $mode='uploaded', $object=null)
Delete files into database index using search criteria.
acceptLocalLinktoMedia()
Check the syntax of some PHP code.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
picto_from_langcode($codelang, $moreatt='', $notitlealt=0)
Return img flag of country for a language code or country code.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='', $textonpictotooltip='')
Show information in HTML for admin users or standard users.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
getDolUserInt($key, $default=0, $tmpuser=null)
Return Dolibarr user constant int value.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
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 '.
dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $disabled='', $morecss='classlink button bordertransp', $jsonopen='', $jsonclose='', $accesskey='')
Return HTML code to output a button to open a dialog popup box.
dolBuildUrl($url, $params=[], $addtoken=false, $anchor='')
Return path of url.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
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.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into JavaScript code.
dol_set_focus($selector)
Set focus onto field with selector (similar behaviour of 'autofocus' HTML5 tag)
GETPOSTFLOAT($paramname, $rounding='', $option=2)
Return the value of a $_GET or $_POST supervariable, converted into float.
dol_print_email($email, $contactid=0, $socid=0, $addlink=0, $max=0, $showinvalid=1, $withpicto=0, $morecss='paddingrightonly')
Show EMail link formatted for HTML output.
yn($yesno, $format=1, $color=0)
Return yes or no in current language.
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.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_clone($srcobject, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
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 a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
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...
treeview li table
No Email.
div refaddress div address
image_format_supported($file, $acceptsvg=0)
Return if a filename is file name of a supported image format.
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
$conf db user
Active Directory does not allow anonymous connections.
if(preg_match('/(crypted|dolcrypt):/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
$conf db name
Only used if Module[ID]Name translation string is not found.
dolJSToSetRandomPassword($htmlname, $htmlnameofbutton='generate_token', $generic=1)
Output javascript 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.
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.
dol_verifyHash($chain, $hash, $type='0')
Compute a hash and compare it to the given one For backward compatibility reasons,...
user_prepare_head(User $object)
Prepare array with list of tabs.