2004-10-20 23:06:45 +02:00
< ? php
2006-12-04 12:38:34 +01:00
/* Copyright ( C ) 2002 - 2006 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2004-06-09 12:39:40 +02:00
* Copyright ( C ) 2002 - 2003 Jean - Louis Bergamo < jlb @ j1b . org >
2020-09-17 15:21:59 +02:00
* Copyright ( C ) 2004 - 2020 Laurent Destailleur < eldy @ users . sourceforge . net >
2004-12-22 21:50:38 +01:00
* Copyright ( C ) 2004 Eric Seigne < eric . seigne @ ryxeo . com >
2021-09-05 15:35:06 +02:00
* Copyright ( C ) 2005 - 2021 Regis Houssin < regis . houssin @ inodbox . com >
2009-04-30 15:28:08 +02:00
* Copyright ( C ) 2005 Lionel Cousteix < etm_ltd @ tiscali . co . uk >
2011-08-19 09:22:17 +02:00
* Copyright ( C ) 2011 Herve Prot < herve . prot @ symeos . com >
2018-12-11 13:25:33 +01:00
* Copyright ( C ) 2012 - 2018 Juanjo Menent < jmenent @ 2 byte . es >
2013-05-07 12:25:32 +02:00
* Copyright ( C ) 2013 Florian Henry < florian . henry @ open - concept . pro >
2019-01-28 21:39:22 +01:00
* Copyright ( C ) 2013 - 2016 Alexandre Spangaro < aspangaro @ open - dsi . fr >
2017-11-28 15:06:23 +01:00
* Copyright ( C ) 2015 - 2017 Jean - François Ferry < jfefe @ aternatik . fr >
2015-07-19 22:43:06 +02:00
* Copyright ( C ) 2015 Ari Elbaz ( elarifr ) < github @ accedinfo . com >
2018-05-12 18:05:06 +02:00
* Copyright ( C ) 2015 - 2018 Charlene Benke < charlie @ patas - monkey . com >
2016-03-18 11:54:14 +01:00
* Copyright ( C ) 2016 Raphaël Doursenaud < rdoursenaud @ gpcsolutions . fr >
2021-03-15 00:59:07 +01:00
* Copyright ( C ) 2018 - 2021 Frédéric France < frederic . france @ netlogic . fr >
2019-02-16 10:29:15 +01:00
* Copyright ( C ) 2018 David Beniamine < David . Beniamine @ Tetras - Libre . fr >
2002-05-06 21:10:48 +02:00
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
2013-01-16 15:36:08 +01:00
* the Free Software Foundation ; either version 3 of the License , or
2002-05-06 21:10:48 +02:00
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
2019-09-23 21:55:30 +02:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
2002-05-06 21:10:48 +02:00
*/
2008-08-28 14:08:02 +02:00
/**
2014-09-18 21:18:25 +02:00
* \file htdocs / user / card . php
2011-05-28 13:50:51 +02:00
* \brief Tab of user card
2008-08-11 01:46:44 +02:00
*/
2004-10-10 17:51:19 +02:00
2012-08-22 23:24:21 +02:00
require '../main.inc.php' ;
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/user/class/user.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/user/class/usergroup.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php' ;
2017-01-06 16:44:09 +01:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php' ;
2020-02-12 17:28:18 +01:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php' ;
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/images.lib.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/usergroups.lib.php' ;
2012-11-30 15:55:59 +01:00
require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php' ;
2020-08-07 14:22:43 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formadmin.class.php' ;
2015-11-18 06:34:08 +01:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php' ;
2014-11-05 14:24:02 +01:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php' ;
2020-04-02 21:34:51 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/security2.lib.php' ;
2021-02-26 13:18:40 +01:00
if ( ! empty ( $conf -> ldap -> enabled )) {
require_once DOL_DOCUMENT_ROOT . '/core/class/ldap.class.php' ;
}
if ( ! empty ( $conf -> adherent -> enabled )) {
require_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php' ;
}
if ( ! empty ( $conf -> categorie -> enabled )) {
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php' ;
}
if ( ! empty ( $conf -> stock -> enabled )) {
require_once DOL_DOCUMENT_ROOT . '/product/class/html.formproduct.class.php' ;
}
2005-09-26 03:01:53 +02:00
2019-11-08 10:53:31 +01:00
$id = GETPOST ( 'id' , 'int' );
2019-01-27 11:55:16 +01:00
$action = GETPOST ( 'action' , 'aZ09' );
2019-11-08 10:53:31 +01:00
$mode = GETPOST ( 'mode' , 'alpha' );
2019-01-27 11:55:16 +01:00
$confirm = GETPOST ( 'confirm' , 'alpha' );
2019-11-08 10:53:31 +01:00
$group = GETPOST ( " group " , " int " , 3 );
2019-01-27 11:55:16 +01:00
$cancel = GETPOST ( 'cancel' , 'alpha' );
2019-11-08 10:53:31 +01:00
$contextpage = GETPOST ( 'contextpage' , 'aZ' ) ? GETPOST ( 'contextpage' , 'aZ' ) : 'useracard' ; // To manage different context of search
2011-11-02 20:17:55 +01:00
2020-09-21 18:44:20 +02:00
$dateemployment = dol_mktime ( 0 , 0 , 0 , GETPOST ( 'dateemploymentmonth' , 'int' ), GETPOST ( 'dateemploymentday' , 'int' ), GETPOST ( 'dateemploymentyear' , 'int' ));
$dateemploymentend = dol_mktime ( 0 , 0 , 0 , GETPOST ( 'dateemploymentendmonth' , 'int' ), GETPOST ( 'dateemploymentendday' , 'int' ), GETPOST ( 'dateemploymentendyear' , 'int' ));
$datestartvalidity = dol_mktime ( 0 , 0 , 0 , GETPOST ( 'datestartvaliditymonth' , 'int' ), GETPOST ( 'datestartvalidityday' , 'int' ), GETPOST ( 'datestartvalidityyear' , 'int' ));
$dateendvalidity = dol_mktime ( 0 , 0 , 0 , GETPOST ( 'dateendvaliditymonth' , 'int' ), GETPOST ( 'dateendvalidityday' , 'int' ), GETPOST ( 'dateendvalidityyear' , 'int' ));
$dateofbirth = dol_mktime ( 0 , 0 , 0 , GETPOST ( 'dateofbirthmonth' , 'int' ), GETPOST ( 'dateofbirthday' , 'int' ), GETPOST ( 'dateofbirthyear' , 'int' ));
2009-07-04 19:29:26 +02:00
// Define value to know what current user can do on users
2019-11-08 10:53:31 +01:00
$canadduser = ( ! empty ( $user -> admin ) || $user -> rights -> user -> user -> creer );
$canreaduser = ( ! empty ( $user -> admin ) || $user -> rights -> user -> user -> lire );
$canedituser = ( ! empty ( $user -> admin ) || $user -> rights -> user -> user -> creer );
$candisableuser = ( ! empty ( $user -> admin ) || $user -> rights -> user -> user -> supprimer );
$canreadgroup = $canreaduser ;
$caneditgroup = $canedituser ;
2021-02-26 13:18:40 +01:00
if ( ! empty ( $conf -> global -> MAIN_USE_ADVANCED_PERMS )) {
2019-11-08 10:53:31 +01:00
$canreadgroup = ( ! empty ( $user -> admin ) || $user -> rights -> user -> group_advance -> read );
$caneditgroup = ( ! empty ( $user -> admin ) || $user -> rights -> user -> group_advance -> write );
2010-11-08 12:40:52 +01:00
}
2018-02-25 15:35:41 +01:00
2021-06-15 14:18:09 +02:00
$childids = $user -> getAllChildIds ( 1 ); // For later, test on salary visibility
2009-07-04 19:29:26 +02:00
// Define value to know what current user can do on properties of edited user
2021-12-19 17:25:11 +01:00
if ( $id > 0 ) {
2021-03-22 13:56:19 +01:00
// $user is the current logged user, $id is the user we want to edit
2021-12-19 17:25:11 +01:00
$caneditfield = ((( $user -> id == $id ) && $user -> rights -> user -> self -> creer ) || (( $user -> id != $id ) && $user -> rights -> user -> user -> creer ));
$caneditpassword = ((( $user -> id == $id ) && $user -> rights -> user -> self -> password ) || (( $user -> id != $id ) && $user -> rights -> user -> user -> password ));
2006-06-14 00:50:36 +02:00
}
2009-04-27 22:37:50 +02:00
// Security check
2019-11-08 10:53:31 +01:00
$socid = 0 ;
2021-02-26 13:18:40 +01:00
if ( $user -> socid > 0 ) {
$socid = $user -> socid ;
}
2019-11-08 10:53:31 +01:00
$feature2 = 'user' ;
2020-02-12 17:28:18 +01:00
$result = restrictedArea ( $user , 'user' , $id , 'user' , $feature2 );
2019-01-15 12:18:04 +01:00
2021-12-19 17:25:11 +01:00
if ( $user -> id != $id && ! $canreaduser ) {
2021-02-26 13:18:40 +01:00
accessforbidden ();
}
2005-08-23 13:40:19 +02:00
2018-05-26 16:24:54 +02:00
// Load translation files required by page
2021-06-09 07:42:05 +02:00
$langs -> loadLangs ( array ( 'users' , 'companies' , 'ldap' , 'admin' , 'hrm' , 'stocks' , 'other' ));
2004-07-31 17:27:37 +02:00
2012-12-02 11:03:23 +01:00
$object = new User ( $db );
2012-11-30 15:55:59 +01:00
$extrafields = new ExtraFields ( $db );
2002-05-06 21:10:48 +02:00
2013-05-07 12:25:32 +02:00
// fetch optionals attributes and labels
2019-10-06 14:41:52 +02:00
$extrafields -> fetch_name_optionals_label ( $object -> table_element );
2013-05-07 12:25:32 +02:00
2019-09-12 20:44:24 +02:00
$socialnetworks = getArrayOfSocialNetworks ();
2019-09-12 20:03:28 +02:00
2015-11-05 13:43:22 +01:00
// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array
2019-10-06 14:41:52 +02:00
$hookmanager -> initHooks ( array ( 'usercard' , 'globalcard' ));
2012-12-12 11:57:56 +01:00
2021-03-22 13:56:19 +01:00
$error = 0 ;
2012-12-12 11:57:56 +01:00
2004-10-01 20:05:38 +02:00
2005-01-28 21:35:01 +01:00
/**
* Actions
*/
2020-10-01 16:21:07 +02:00
2019-11-08 10:53:31 +01:00
$parameters = array ( 'id' => $id , 'socid' => $socid , 'group' => $group , 'caneditgroup' => $caneditgroup );
$reshook = $hookmanager -> executeHooks ( 'doActions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by some hooks
2021-02-26 13:18:40 +01:00
if ( $reshook < 0 ) {
setEventMessages ( $hookmanager -> error , $hookmanager -> errors , 'errors' );
}
2014-07-20 00:10:40 +02:00
2015-09-16 09:37:49 +02:00
if ( empty ( $reshook )) {
2021-09-02 21:35:36 +02:00
$backurlforlist = DOL_URL_ROOT . '/user/list.php' ;
if ( empty ( $backtopage ) || ( $cancel && empty ( $id ))) {
if ( empty ( $backtopage ) || ( $cancel && strpos ( $backtopage , '__ID__' ))) {
if ( empty ( $id ) && (( $action != 'add' && $action != 'create' ) || $cancel )) {
$backtopage = $backurlforlist ;
} else {
$backtopage = DOL_URL_ROOT . '/user/card.php?id=' . (( ! empty ( $id ) && $id > 0 ) ? $id : '__ID__' );
}
}
}
if ( $cancel ) {
if ( ! empty ( $backtopageforcancel )) {
header ( " Location: " . $backtopageforcancel );
exit ;
} elseif ( ! empty ( $backtopage )) {
header ( " Location: " . $backtopage );
exit ;
}
$action = '' ;
}
2015-10-15 16:16:50 +02:00
if ( $action == 'confirm_disable' && $confirm == " yes " && $candisableuser ) {
2021-06-15 20:16:05 +02:00
if ( $id != $user -> id ) { // A user can't disable itself
2015-10-15 16:16:50 +02:00
$object -> fetch ( $id );
2021-03-22 13:56:19 +01:00
if ( $object -> admin && empty ( $user -> admin )) {
// If user to delete is an admin user and if logged user is not admin, we deny the operation.
$error ++ ;
setEventMessages ( $langs -> trans ( " OnlyAdminUsersCanDisableAdminUsers " ), null , 'errors' );
} else {
$object -> setstatus ( 0 );
header ( " Location: " . $_SERVER [ 'PHP_SELF' ] . '?id=' . $id );
exit ;
}
2015-10-15 16:16:50 +02:00
}
}
2021-06-15 20:16:05 +02:00
2015-10-15 16:16:50 +02:00
if ( $action == 'confirm_enable' && $confirm == " yes " && $candisableuser ) {
$error = 0 ;
2015-09-16 09:37:49 +02:00
2021-06-15 20:16:05 +02:00
if ( $id != $user -> id ) {
2015-10-15 16:16:50 +02:00
$object -> fetch ( $id );
2003-08-10 14:44:43 +02:00
2015-10-15 16:16:50 +02:00
if ( ! empty ( $conf -> file -> main_limit_users )) {
$nb = $object -> getNbOfUsers ( " active " );
if ( $nb >= $conf -> file -> main_limit_users ) {
2019-11-08 10:53:31 +01:00
$error ++ ;
2015-12-21 14:43:21 +01:00
setEventMessages ( $langs -> trans ( " YourQuotaOfUsersIsReached " ), null , 'errors' );
2015-10-15 16:16:50 +02:00
}
}
2014-07-20 00:10:40 +02:00
2015-10-15 16:16:50 +02:00
if ( ! $error ) {
$object -> setstatus ( 1 );
header ( " Location: " . $_SERVER [ 'PHP_SELF' ] . '?id=' . $id );
exit ;
}
}
}
2011-06-29 12:23:32 +02:00
2021-02-26 13:18:40 +01:00
if ( $action == 'confirm_delete' && $confirm == " yes " && $candisableuser ) {
2021-06-15 20:16:05 +02:00
if ( $id != $user -> id ) {
2021-02-26 13:18:40 +01:00
if ( ! GETPOSTISSET ( 'token' )) {
2018-12-22 18:09:26 +01:00
print 'Error, token required for this critical operation' ;
exit ;
}
2015-10-15 16:16:50 +02:00
$object = new User ( $db );
2016-12-07 19:16:33 +01:00
$object -> fetch ( $id );
2020-09-07 10:18:17 +02:00
$object -> oldcopy = clone $object ;
2018-12-22 18:09:26 +01:00
2018-12-22 17:34:27 +01:00
$result = $object -> delete ( $user );
2015-10-15 16:16:50 +02:00
if ( $result < 0 ) {
$langs -> load ( " errors " );
2015-12-21 14:43:21 +01:00
setEventMessages ( $langs -> trans ( " ErrorUserCannotBeDelete " ), null , 'errors' );
2015-10-15 16:16:50 +02:00
} else {
2018-12-22 18:09:26 +01:00
setEventMessages ( $langs -> trans ( " RecordDeleted " ), null );
2018-12-11 13:25:33 +01:00
header ( " Location: " . DOL_URL_ROOT . " /user/list.php?restore_lastsearch_values=1 " );
2015-10-15 16:16:50 +02:00
exit ;
}
}
}
2011-06-29 12:23:32 +02:00
2015-10-15 16:16:50 +02:00
// Action Add user
if ( $action == 'add' && $canadduser ) {
$error = 0 ;
2011-06-29 12:23:32 +02:00
2021-03-24 19:53:31 +01:00
if ( ! GETPOST ( " lastname " )) {
2019-11-08 10:53:31 +01:00
$error ++ ;
2015-12-21 14:43:21 +01:00
setEventMessages ( $langs -> trans ( " NameNotDefined " ), null , 'errors' );
2019-11-08 10:53:31 +01:00
$action = " create " ; // Go back to create page
2015-10-15 16:16:50 +02:00
}
2021-03-24 19:53:31 +01:00
if ( ! GETPOST ( " login " )) {
2019-11-08 10:53:31 +01:00
$error ++ ;
2015-12-21 14:43:21 +01:00
setEventMessages ( $langs -> trans ( " LoginNotDefined " ), null , 'errors' );
2019-11-08 10:53:31 +01:00
$action = " create " ; // Go back to create page
2015-10-15 16:16:50 +02:00
}
2011-06-29 12:23:32 +02:00
2015-10-15 16:16:50 +02:00
if ( ! empty ( $conf -> file -> main_limit_users )) { // If option to limit users is set
$nb = $object -> getNbOfUsers ( " active " );
if ( $nb >= $conf -> file -> main_limit_users ) {
2019-11-08 10:53:31 +01:00
$error ++ ;
2015-12-21 14:43:21 +01:00
setEventMessages ( $langs -> trans ( " YourQuotaOfUsersIsReached " ), null , 'errors' );
2019-11-08 10:53:31 +01:00
$action = " create " ; // Go back to create page
2015-10-15 16:16:50 +02:00
}
}
2011-06-29 12:23:32 +02:00
2015-10-15 16:16:50 +02:00
if ( ! $error ) {
2020-12-05 11:30:18 +01:00
$object -> civility_code = GETPOST ( " civility_code " , 'aZ09' );
2019-09-24 14:16:24 +02:00
$object -> lastname = GETPOST ( " lastname " , 'alphanohtml' );
$object -> firstname = GETPOST ( " firstname " , 'alphanohtml' );
$object -> login = GETPOST ( " login " , 'alphanohtml' );
$object -> api_key = GETPOST ( " api_key " , 'alphanohtml' );
$object -> gender = GETPOST ( " gender " , 'aZ09' );
$object -> admin = GETPOST ( " admin " , 'int' );
2018-11-15 17:34:11 +01:00
$object -> address = GETPOST ( 'address' , 'alphanohtml' );
2018-12-22 17:08:55 +01:00
$object -> zip = GETPOST ( 'zipcode' , 'alphanohtml' );
$object -> town = GETPOST ( 'town' , 'alphanohtml' );
2015-11-18 06:34:08 +01:00
$object -> country_id = GETPOST ( 'country_id' , 'int' );
$object -> state_id = GETPOST ( 'state_id' , 'int' );
2018-12-22 17:08:55 +01:00
$object -> office_phone = GETPOST ( " office_phone " , 'alphanohtml' );
$object -> office_fax = GETPOST ( " office_fax " , 'alphanohtml' );
$object -> user_mobile = GETPOST ( " user_mobile " , 'alphanohtml' );
2018-12-22 19:06:58 +01:00
2019-11-08 10:53:31 +01:00
if ( ! empty ( $conf -> socialnetworks -> enabled )) {
2021-05-12 11:04:22 +02:00
$object -> socialnetworks = array ();
2019-09-12 20:03:28 +02:00
foreach ( $socialnetworks as $key => $value ) {
2021-05-12 11:04:22 +02:00
if ( GETPOST ( $key , 'alphanohtml' )) {
$object -> socialnetworks [ $key ] = GETPOST ( $key , 'alphanohtml' );
}
2019-09-12 20:03:28 +02:00
}
}
2018-12-22 19:06:58 +01:00
2019-09-24 14:16:24 +02:00
$object -> email = preg_replace ( '/\s+/' , '' , GETPOST ( " email " , 'alphanohtml' ));
2020-09-19 03:25:25 +02:00
$object -> job = GETPOST ( " job " , 'alphanohtml' );
2020-09-18 01:29:17 +02:00
$object -> signature = GETPOST ( " signature " , 'restricthtml' );
2018-12-22 17:08:55 +01:00
$object -> accountancy_code = GETPOST ( " accountancy_code " , 'alphanohtml' );
2020-09-18 01:29:17 +02:00
$object -> note = GETPOST ( " note " , 'restricthtml' );
$object -> note_private = GETPOST ( " note " , 'restricthtml' );
2018-12-22 17:08:55 +01:00
$object -> ldap_sid = GETPOST ( " ldap_sid " , 'alphanohtml' );
$object -> fk_user = GETPOST ( " fk_user " , 'int' ) > 0 ? GETPOST ( " fk_user " , 'int' ) : 0 ;
2019-10-02 08:43:40 +02:00
$object -> fk_user_expense_validator = GETPOST ( " fk_user_expense_validator " , 'int' ) > 0 ? GETPOST ( " fk_user_expense_validator " , 'int' ) : 0 ;
$object -> fk_user_holiday_validator = GETPOST ( " fk_user_holiday_validator " , 'int' ) > 0 ? GETPOST ( " fk_user_holiday_validator " , 'int' ) : 0 ;
2018-12-22 17:08:55 +01:00
$object -> employee = GETPOST ( 'employee' , 'alphanohtml' );
$object -> thm = GETPOST ( " thm " , 'alphanohtml' ) != '' ? GETPOST ( " thm " , 'alphanohtml' ) : '' ;
2019-12-02 10:34:14 +01:00
$object -> thm = price2num ( $object -> thm );
2018-12-22 17:08:55 +01:00
$object -> tjm = GETPOST ( " tjm " , 'alphanohtml' ) != '' ? GETPOST ( " tjm " , 'alphanohtml' ) : '' ;
2020-04-10 10:59:32 +02:00
$object -> tjm = price2num ( $object -> tjm );
2018-12-22 17:08:55 +01:00
$object -> salary = GETPOST ( " salary " , 'alphanohtml' ) != '' ? GETPOST ( " salary " , 'alphanohtml' ) : '' ;
2019-12-02 10:34:14 +01:00
$object -> salary = price2num ( $object -> salary );
2018-12-22 17:08:55 +01:00
$object -> salaryextra = GETPOST ( " salaryextra " , 'alphanohtml' ) != '' ? GETPOST ( " salaryextra " , 'alphanohtml' ) : '' ;
$object -> weeklyhours = GETPOST ( " weeklyhours " , 'alphanohtml' ) != '' ? GETPOST ( " weeklyhours " , 'alphanohtml' ) : '' ;
$object -> color = GETPOST ( " color " , 'alphanohtml' ) != '' ? GETPOST ( " color " , 'alphanohtml' ) : '' ;
2015-10-15 16:16:50 +02:00
2020-09-21 18:44:20 +02:00
$object -> dateemployment = $dateemployment ;
2018-05-12 18:05:06 +02:00
$object -> dateemploymentend = $dateemploymentend ;
2020-09-21 18:44:20 +02:00
$object -> datestartvalidity = $datestartvalidity ;
$object -> dateendvalidity = $dateendvalidity ;
$object -> birth = $dateofbirth ;
2018-05-12 18:05:06 +02:00
2019-02-15 05:24:25 +01:00
$object -> fk_warehouse = GETPOST ( 'fk_warehouse' , 'int' );
2020-08-07 14:22:43 +02:00
$object -> lang = GETPOST ( 'default_lang' , 'aZ09' );
2015-10-15 16:16:50 +02:00
// Fill array 'array_options' with data from add form
2019-10-06 14:41:52 +02:00
$ret = $extrafields -> setOptionalsFromPost ( null , $object );
2015-10-15 16:16:50 +02:00
if ( $ret < 0 ) {
2019-11-08 10:53:31 +01:00
$error ++ ;
2015-10-15 16:16:50 +02:00
}
2011-06-29 12:23:32 +02:00
2015-10-15 16:16:50 +02:00
// Set entity property
$entity = GETPOST ( 'entity' , 'int' );
2019-11-08 10:53:31 +01:00
if ( ! empty ( $conf -> multicompany -> enabled )) {
2017-06-06 07:57:03 +02:00
if ( GETPOST ( 'superadmin' , 'int' )) {
2015-10-15 16:16:50 +02:00
$object -> entity = 0 ;
} else {
2019-11-08 10:53:31 +01:00
if ( ! empty ( $conf -> global -> MULTICOMPANY_TRANSVERSE_MODE )) {
2015-10-15 16:16:50 +02:00
$object -> entity = 1 ; // all users are forced into master entity
} else {
$object -> entity = ( $entity == '' ? 1 : $entity );
}
}
} else {
$object -> entity = ( $entity == '' ? 1 : $entity );
2017-10-07 13:09:31 +02:00
/* if ( $user -> admin && $user -> entity == 0 && GETPOST ( " admin " , 'alpha' ))
2015-09-16 09:37:49 +02:00
{
} */
2015-10-15 16:16:50 +02:00
}
2008-08-28 14:08:02 +02:00
2015-10-15 16:16:50 +02:00
$db -> begin ();
2011-05-28 13:50:51 +02:00
2015-10-15 16:16:50 +02:00
$id = $object -> create ( $user );
if ( $id > 0 ) {
2021-07-20 22:42:23 +02:00
if ( GETPOST ( 'password' , 'none' )) {
2021-07-20 23:03:19 +02:00
$object -> setPassword ( $user , GETPOST ( 'password' , 'none' ));
2015-10-15 16:16:50 +02:00
}
2019-11-08 10:53:31 +01:00
if ( ! empty ( $conf -> categorie -> enabled )) {
2016-02-13 10:42:45 +01:00
// Categories association
2017-09-18 01:39:39 +02:00
$usercats = GETPOST ( 'usercats' , 'array' );
2016-02-13 10:42:45 +01:00
$object -> setCategories ( $usercats );
}
2015-10-15 16:16:50 +02:00
$db -> commit ();
header ( " Location: " . $_SERVER [ 'PHP_SELF' ] . '?id=' . $id );
exit ;
2020-05-21 15:05:19 +02:00
} else {
2015-10-15 16:16:50 +02:00
$langs -> load ( " errors " );
$db -> rollback ();
2016-09-10 13:00:31 +02:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2019-11-08 10:53:31 +01:00
$action = " create " ; // Go back to create page
2015-10-15 16:16:50 +02:00
}
2015-10-15 16:11:03 +02:00
}
2015-10-15 16:16:50 +02:00
}
2011-06-29 12:23:32 +02:00
2015-10-15 16:16:50 +02:00
// Action add usergroup
2021-02-26 13:18:40 +01:00
if (( $action == 'addgroup' || $action == 'removegroup' ) && $caneditgroup ) {
if ( $group ) {
2015-10-15 16:16:50 +02:00
$editgroup = new UserGroup ( $db );
$editgroup -> fetch ( $group );
2019-11-08 10:53:31 +01:00
$editgroup -> oldcopy = clone $editgroup ;
2015-10-15 16:16:50 +02:00
$object -> fetch ( $id );
if ( $action == 'addgroup' ) {
2017-11-04 15:40:35 +01:00
$result = $object -> SetInGroup ( $group , $editgroup -> entity );
2015-10-15 16:16:50 +02:00
}
if ( $action == 'removegroup' ) {
2017-11-04 15:40:35 +01:00
$result = $object -> RemoveFromGroup ( $group , $editgroup -> entity );
2015-10-15 16:16:50 +02:00
}
2013-01-10 21:32:10 +01:00
2015-10-15 16:16:50 +02:00
if ( $result > 0 ) {
2021-11-25 10:28:37 +01:00
$action = '' ;
2020-05-21 15:05:19 +02:00
} else {
2015-12-21 14:43:21 +01:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2015-10-15 16:16:50 +02:00
}
2015-10-15 16:11:03 +02:00
}
}
2013-01-10 21:32:10 +01:00
2021-02-26 13:18:40 +01:00
if ( $action == 'update' && ! $cancel ) {
2015-10-15 16:16:50 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php' ;
2014-09-13 17:41:26 +02:00
2021-02-26 13:18:40 +01:00
if ( $caneditfield ) { // Case we can edit all field
2015-10-15 16:16:50 +02:00
$error = 0 ;
2012-12-12 11:57:56 +01:00
2019-11-08 10:53:31 +01:00
if ( ! GETPOST ( " lastname " , 'alpha' )) {
2016-03-17 09:22:12 +01:00
setEventMessages ( $langs -> trans ( " NameNotDefined " ), null , 'errors' );
2019-11-08 10:53:31 +01:00
$action = " edit " ; // Go back to create page
$error ++ ;
2016-03-17 09:22:12 +01:00
}
2019-11-08 10:53:31 +01:00
if ( ! GETPOST ( " login " , 'alpha' )) {
2016-03-17 09:22:12 +01:00
setEventMessages ( $langs -> trans ( " LoginNotDefined " ), null , 'errors' );
2019-11-08 10:53:31 +01:00
$action = " edit " ; // Go back to create page
$error ++ ;
2016-03-17 09:22:12 +01:00
}
2011-06-29 12:23:32 +02:00
2021-02-26 13:18:40 +01:00
if ( ! $error ) {
2016-03-17 09:22:12 +01:00
$object -> fetch ( $id );
$object -> oldcopy = clone $object ;
2017-02-28 11:16:07 +01:00
$db -> begin ();
2020-12-05 11:30:18 +01:00
$object -> civility_code = GETPOST ( " civility_code " , 'aZ09' );
2019-09-24 14:16:24 +02:00
$object -> lastname = GETPOST ( " lastname " , 'alphanohtml' );
$object -> firstname = GETPOST ( " firstname " , 'alphanohtml' );
$object -> login = GETPOST ( " login " , 'alphanohtml' );
$object -> gender = GETPOST ( " gender " , 'aZ09' );
2022-01-19 15:20:10 +01:00
$object -> pass = GETPOST ( " password " , 'none' ); // We can keep 'none' for password fields
2019-09-24 14:16:24 +02:00
$object -> api_key = ( GETPOST ( " api_key " , 'alphanohtml' )) ? GETPOST ( " api_key " , 'alphanohtml' ) : $object -> api_key ;
2021-02-26 13:18:40 +01:00
if ( ! empty ( $user -> admin )) {
$object -> admin = GETPOST ( " admin " , " int " ); // admin flag can only be set/unset by an admin user. A test is also done later when forging sql request
}
2018-11-15 17:34:11 +01:00
$object -> address = GETPOST ( 'address' , 'alphanohtml' );
2018-12-22 17:08:55 +01:00
$object -> zip = GETPOST ( 'zipcode' , 'alphanohtml' );
$object -> town = GETPOST ( 'town' , 'alphanohtml' );
2017-02-28 11:16:07 +01:00
$object -> country_id = GETPOST ( 'country_id' , 'int' );
$object -> state_id = GETPOST ( 'state_id' , 'int' );
2018-12-22 17:08:55 +01:00
$object -> office_phone = GETPOST ( " office_phone " , 'alphanohtml' );
$object -> office_fax = GETPOST ( " office_fax " , 'alphanohtml' );
$object -> user_mobile = GETPOST ( " user_mobile " , 'alphanohtml' );
2021-10-27 16:39:34 +02:00
2019-11-08 10:53:31 +01:00
if ( ! empty ( $conf -> socialnetworks -> enabled )) {
2021-05-12 11:04:22 +02:00
$object -> socialnetworks = array ();
2019-09-12 20:03:28 +02:00
foreach ( $socialnetworks as $key => $value ) {
2021-05-12 11:04:22 +02:00
if ( GETPOST ( $key , 'alphanohtml' )) {
$object -> socialnetworks [ $key ] = GETPOST ( $key , 'alphanohtml' );
}
2019-09-12 20:03:28 +02:00
}
}
2021-10-27 16:39:34 +02:00
2019-09-24 14:16:24 +02:00
$object -> email = preg_replace ( '/\s+/' , '' , GETPOST ( " email " , 'alphanohtml' ));
2020-09-19 03:25:25 +02:00
$object -> job = GETPOST ( " job " , 'alphanohtml' );
2020-09-18 01:29:17 +02:00
$object -> signature = GETPOST ( " signature " , 'restricthtml' );
2019-09-24 14:16:24 +02:00
$object -> accountancy_code = GETPOST ( " accountancy_code " , 'alphanohtml' );
$object -> openid = GETPOST ( " openid " , 'alphanohtml' );
2019-01-27 11:55:16 +01:00
$object -> fk_user = GETPOST ( " fk_user " , 'int' ) > 0 ? GETPOST ( " fk_user " , 'int' ) : 0 ;
2019-10-02 08:43:40 +02:00
$object -> fk_user_expense_validator = GETPOST ( " fk_user_expense_validator " , 'int' ) > 0 ? GETPOST ( " fk_user_expense_validator " , 'int' ) : 0 ;
$object -> fk_user_holiday_validator = GETPOST ( " fk_user_holiday_validator " , 'int' ) > 0 ? GETPOST ( " fk_user_holiday_validator " , 'int' ) : 0 ;
2019-01-27 11:55:16 +01:00
$object -> employee = GETPOST ( 'employee' , 'int' );
$object -> thm = GETPOST ( " thm " , 'alphanohtml' ) != '' ? GETPOST ( " thm " , 'alphanohtml' ) : '' ;
2019-12-03 13:52:42 +01:00
$object -> thm = price2num ( $object -> thm );
2019-01-27 11:55:16 +01:00
$object -> tjm = GETPOST ( " tjm " , 'alphanohtml' ) != '' ? GETPOST ( " tjm " , 'alphanohtml' ) : '' ;
2019-12-02 10:34:14 +01:00
$object -> thm = price2num ( $object -> thm );
2019-01-27 11:55:16 +01:00
$object -> salary = GETPOST ( " salary " , 'alphanohtml' ) != '' ? GETPOST ( " salary " , 'alphanohtml' ) : '' ;
2019-12-02 10:34:14 +01:00
$object -> salary = price2num ( $object -> salary );
2019-01-27 11:55:16 +01:00
$object -> salaryextra = GETPOST ( " salaryextra " , 'alphanohtml' ) != '' ? GETPOST ( " salaryextra " , 'alphanohtml' ) : '' ;
2019-12-03 13:52:42 +01:00
$object -> salaryextra = price2num ( $object -> salaryextra );
2019-01-27 11:55:16 +01:00
$object -> weeklyhours = GETPOST ( " weeklyhours " , 'alphanohtml' ) != '' ? GETPOST ( " weeklyhours " , 'alphanohtml' ) : '' ;
2019-12-03 13:52:42 +01:00
$object -> weeklyhours = price2num ( $object -> weeklyhours );
2019-01-27 11:55:16 +01:00
2019-09-24 14:16:24 +02:00
$object -> color = GETPOST ( " color " , 'alphanohtml' ) != '' ? GETPOST ( " color " , 'alphanohtml' ) : '' ;
2017-02-28 11:16:07 +01:00
$object -> dateemployment = $dateemployment ;
2018-05-12 18:05:06 +02:00
$object -> dateemploymentend = $dateemploymentend ;
2020-09-21 18:44:20 +02:00
$object -> datestartvalidity = $datestartvalidity ;
$object -> dateendvalidity = $dateendvalidity ;
$object -> birth = $dateofbirth ;
2019-02-27 13:48:13 +01:00
2021-02-26 13:18:40 +01:00
if ( ! empty ( $conf -> stock -> enabled )) {
2020-09-07 10:18:17 +02:00
$object -> fk_warehouse = GETPOST ( 'fk_warehouse' , 'int' );
}
2019-02-27 13:48:13 +01:00
2020-09-07 10:18:17 +02:00
$object -> lang = GETPOST ( 'default_lang' , 'aZ09' );
2020-08-07 14:22:43 +02:00
2021-06-13 16:15:05 +02:00
// Do we update also ->entity ?
2021-11-11 17:48:23 +01:00
if ( ! empty ( $conf -> multicompany -> enabled && $user -> entity == 0 && ! empty ( $user -> admin ))) { // If multicompany is not enabled, we never update the entity of a user.
if ( GETPOST ( 'superadmin' , 'int' )) {
$object -> entity = 0 ;
2020-05-21 15:05:19 +02:00
} else {
2021-11-11 17:48:23 +01:00
if ( ! empty ( $conf -> global -> MULTICOMPANY_TRANSVERSE_MODE )) {
$object -> entity = 1 ; // all users are in master entity
} else {
// We try to change the entity of user
$object -> entity = ( GETPOSTISSET ( 'entity' ) ? GETPOSTINT ( 'entity' ) : $object -> entity );
2021-06-13 16:15:05 +02:00
}
2016-03-17 09:22:12 +01:00
}
2017-02-28 11:16:07 +01:00
}
2011-06-29 12:23:32 +02:00
2017-02-28 11:16:07 +01:00
// Fill array 'array_options' with data from add form
2021-12-06 11:19:12 +01:00
$ret = $extrafields -> setOptionalsFromPost ( null , $object , '@GETPOSTISSET' );
2017-02-28 11:16:07 +01:00
if ( $ret < 0 ) {
2019-11-08 10:53:31 +01:00
$error ++ ;
2017-02-28 11:16:07 +01:00
}
2013-01-10 20:07:44 +01:00
2017-02-28 11:16:07 +01:00
if ( GETPOST ( 'deletephoto' )) {
$object -> photo = '' ;
}
2021-02-26 13:18:40 +01:00
if ( ! empty ( $_FILES [ 'photo' ][ 'name' ])) {
2020-09-07 10:18:17 +02:00
$isimage = image_format_supported ( $_FILES [ 'photo' ][ 'name' ]);
2021-02-26 13:18:40 +01:00
if ( $isimage > 0 ) {
2020-09-07 10:18:17 +02:00
$object -> photo = dol_sanitizeFileName ( $_FILES [ 'photo' ][ 'name' ]);
} else {
$error ++ ;
$langs -> load ( " errors " );
setEventMessages ( $langs -> trans ( " ErrorBadImageFormat " ), null , 'errors' );
dol_syslog ( $langs -> transnoentities ( " ErrorBadImageFormat " ), LOG_INFO );
}
2017-02-28 11:16:07 +01:00
}
2015-09-16 09:37:49 +02:00
2017-02-28 11:16:07 +01:00
if ( ! $error ) {
$ret = $object -> update ( $user );
if ( $ret < 0 ) {
$error ++ ;
if ( $db -> errno () == 'DB_ERROR_RECORD_ALREADY_EXISTS' ) {
$langs -> load ( " errors " );
setEventMessages ( $langs -> trans ( " ErrorLoginAlreadyExists " , $object -> login ), null , 'errors' );
2020-05-21 15:05:19 +02:00
} else {
2017-02-28 11:16:07 +01:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2022-01-21 15:40:37 +01:00
$action = 'edit' ;
2016-03-17 09:22:12 +01:00
}
}
2017-02-28 11:16:07 +01:00
}
2011-06-29 12:23:32 +02:00
2017-11-29 15:07:09 +01:00
if ( ! $error && GETPOSTISSET ( 'contactid' )) {
2017-12-19 16:16:31 +01:00
$contactid = GETPOST ( 'contactid' , 'int' );
2020-04-29 20:21:17 +02:00
$socid = GETPOST ( 'socid' , 'int' );
2016-03-17 09:22:12 +01:00
2020-04-29 20:21:17 +02:00
if ( $contactid > 0 ) { // The 'contactid' is used inpriority over the 'socid'
2017-02-28 11:16:07 +01:00
$contact = new Contact ( $db );
$contact -> fetch ( $contactid );
2016-03-17 09:22:12 +01:00
2017-02-28 11:16:07 +01:00
$sql = " UPDATE " . MAIN_DB_PREFIX . " user " ;
2020-04-29 20:21:17 +02:00
$sql .= " SET fk_socpeople= " . (( int ) $contactid );
2017-02-28 11:16:07 +01:00
if ( ! empty ( $contact -> socid )) {
2020-04-29 20:21:17 +02:00
$sql .= " , fk_soc= " . (( int ) $contact -> socid );
2016-03-17 09:22:12 +01:00
}
2021-08-27 18:18:50 +02:00
$sql .= " WHERE rowid = " . (( int ) $object -> id );
2020-04-29 20:21:17 +02:00
} elseif ( $socid > 0 ) {
$sql = " UPDATE " . MAIN_DB_PREFIX . " user " ;
$sql .= " SET fk_socpeople=NULL, fk_soc= " . (( int ) $socid );
2021-08-27 18:18:50 +02:00
$sql .= " WHERE rowid = " . (( int ) $object -> id );
2017-02-28 11:16:07 +01:00
} else {
$sql = " UPDATE " . MAIN_DB_PREFIX . " user " ;
$sql .= " SET fk_socpeople=NULL, fk_soc=NULL " ;
2021-08-27 18:18:50 +02:00
$sql .= " WHERE rowid = " . (( int ) $object -> id );
2016-03-17 09:22:12 +01:00
}
2017-02-28 11:16:07 +01:00
dol_syslog ( " usercard::update " , LOG_DEBUG );
$resql = $db -> query ( $sql );
if ( ! $resql ) {
2019-11-08 10:53:31 +01:00
$error ++ ;
2017-02-28 11:16:07 +01:00
setEventMessages ( $db -> lasterror (), null , 'errors' );
}
}
2011-11-02 18:05:45 +01:00
2017-02-28 11:16:07 +01:00
if ( ! $error && ! count ( $object -> errors )) {
2020-12-10 18:58:11 +01:00
if ( GETPOST ( 'deletephoto' ) && $object -> oldcopy -> photo ) {
$fileimg = $conf -> user -> dir_output . '/' . get_exdir ( 0 , 0 , 0 , 0 , $object , 'user' ) . $object -> oldcopy -> photo ;
$dirthumbs = $conf -> user -> dir_output . '/' . get_exdir ( 0 , 0 , 0 , 0 , $object , 'user' ) . '/thumbs' ;
2017-02-28 11:16:07 +01:00
dol_delete_file ( $fileimg );
dol_delete_dir_recursive ( $dirthumbs );
}
2016-03-17 09:22:12 +01:00
2017-02-28 11:16:07 +01:00
if ( isset ( $_FILES [ 'photo' ][ 'tmp_name' ]) && trim ( $_FILES [ 'photo' ][ 'tmp_name' ])) {
2020-12-10 18:58:11 +01:00
$dir = $conf -> user -> dir_output . '/' . get_exdir ( 0 , 0 , 0 , 1 , $object , 'user' );
2016-03-17 09:22:12 +01:00
2017-02-28 11:16:07 +01:00
dol_mkdir ( $dir );
2016-03-17 09:22:12 +01:00
2017-02-28 11:16:07 +01:00
if ( @ is_dir ( $dir )) {
$newfile = $dir . '/' . dol_sanitizeFileName ( $_FILES [ 'photo' ][ 'name' ]);
$result = dol_move_uploaded_file ( $_FILES [ 'photo' ][ 'tmp_name' ], $newfile , 1 , 0 , $_FILES [ 'photo' ][ 'error' ]);
2016-03-17 09:22:12 +01:00
2017-02-28 11:16:07 +01:00
if ( ! $result > 0 ) {
setEventMessages ( $langs -> trans ( " ErrorFailedToSaveFile " ), null , 'errors' );
2016-03-17 09:22:12 +01:00
} else {
2017-10-07 13:09:31 +02:00
// Create thumbs
$object -> addThumbs ( $newfile );
2016-03-17 09:22:12 +01:00
}
2017-02-28 11:16:07 +01:00
} else {
2019-11-08 10:53:31 +01:00
$error ++ ;
2016-03-17 09:22:12 +01:00
$langs -> load ( " errors " );
2017-02-28 11:16:07 +01:00
setEventMessages ( $langs -> trans ( " ErrorFailedToCreateDir " , $dir ), $mesgs , 'errors' );
2016-03-17 09:22:12 +01:00
}
}
2017-02-28 11:16:07 +01:00
}
2017-06-06 07:57:03 +02:00
2021-02-26 13:18:40 +01:00
if ( ! $error && ! count ( $object -> errors )) {
2017-10-07 13:09:31 +02:00
// Then we add the associated categories
$categories = GETPOST ( 'usercats' , 'array' );
$object -> setCategories ( $categories );
}
2017-02-28 11:16:07 +01:00
if ( ! $error && ! count ( $object -> errors )) {
setEventMessages ( $langs -> trans ( " UserModified " ), null , 'mesgs' );
$db -> commit ();
2017-06-06 07:57:03 +02:00
2017-02-28 11:16:07 +01:00
$login = $_SESSION [ " dol_login " ];
2021-02-26 13:18:40 +01:00
if ( $login && $login == $object -> oldcopy -> login && $object -> oldcopy -> login != $object -> login ) { // Current user has changed its login
2017-02-28 11:16:07 +01:00
$error ++ ;
$langs -> load ( " errors " );
setEventMessages ( $langs -> transnoentitiesnoconv ( " WarningYourLoginWasModifiedPleaseLogin " ), null , 'warnings' );
2016-03-18 11:54:14 +01:00
}
2020-05-21 15:05:19 +02:00
} else {
2017-10-07 13:09:31 +02:00
$db -> rollback ();
2017-02-28 11:16:07 +01:00
}
2017-10-07 13:09:31 +02:00
}
2020-05-21 15:05:19 +02:00
} else {
2021-02-26 13:18:40 +01:00
if ( $caneditpassword ) { // Case we can edit only password
2017-10-07 13:09:31 +02:00
dol_syslog ( " Not allowed to change fields, only password " );
2017-06-06 07:57:03 +02:00
2017-10-07 13:09:31 +02:00
$object -> fetch ( $id );
2017-06-06 07:57:03 +02:00
2020-02-12 17:28:18 +01:00
if ( GETPOST ( " password " , " none " )) { // If pass is empty, we do not change it.
$object -> oldcopy = clone $object ;
2017-06-06 07:57:03 +02:00
2020-02-12 17:28:18 +01:00
$ret = $object -> setPassword ( $user , GETPOST ( " password " , " none " ));
2021-02-26 13:18:40 +01:00
if ( $ret < 0 ) {
2020-02-12 17:28:18 +01:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
}
2017-10-07 13:09:31 +02:00
}
}
2016-03-17 23:58:04 +01:00
}
2016-03-17 09:22:12 +01:00
}
2002-05-06 21:10:48 +02:00
2015-10-15 16:16:50 +02:00
// Change password with a new generated one
2017-10-07 13:09:31 +02:00
if ((( $action == 'confirm_password' && $confirm == 'yes' )
|| ( $action == 'confirm_passwordsend' && $confirm == 'yes' )) && $caneditpassword
) {
$object -> fetch ( $id );
2022-01-03 12:26:57 +01:00
$newpassword = $object -> setPassword ( $user , '' ); // This will generate a new password
2017-10-07 13:09:31 +02:00
if ( $newpassword < 0 ) {
// Echec
setEventMessages ( $langs -> trans ( " ErrorFailedToSetNewPassword " ), null , 'errors' );
} else {
// Succes
if ( $action == 'confirm_passwordsend' && $confirm == 'yes' ) {
2021-02-26 13:18:40 +01:00
if ( $object -> send_password ( $user , $newpassword ) > 0 ) {
2017-10-07 13:09:31 +02:00
setEventMessages ( $langs -> trans ( " PasswordChangedAndSentTo " , $object -> email ), null , 'mesgs' );
2020-05-21 15:05:19 +02:00
} else {
2017-10-07 13:09:31 +02:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
}
2020-05-21 15:05:19 +02:00
} else {
2017-10-07 13:09:31 +02:00
setEventMessages ( $langs -> trans ( " PasswordChangedTo " , $newpassword ), null , 'warnings' );
}
}
}
2002-05-06 21:10:48 +02:00
2015-10-15 16:16:50 +02:00
// Action initialisation donnees depuis record LDAP
2021-05-24 22:11:24 +02:00
if ( $action == 'adduserldap' && $canadduser ) {
$selecteduser = GETPOST ( 'users' );
2017-10-07 13:09:31 +02:00
$required_fields = array (
$conf -> global -> LDAP_KEY_USERS ,
$conf -> global -> LDAP_FIELD_NAME ,
$conf -> global -> LDAP_FIELD_FIRSTNAME ,
$conf -> global -> LDAP_FIELD_LOGIN ,
$conf -> global -> LDAP_FIELD_LOGIN_SAMBA ,
$conf -> global -> LDAP_FIELD_PASSWORD ,
$conf -> global -> LDAP_FIELD_PASSWORD_CRYPTED ,
$conf -> global -> LDAP_FIELD_PHONE ,
$conf -> global -> LDAP_FIELD_FAX ,
$conf -> global -> LDAP_FIELD_MOBILE ,
$conf -> global -> LDAP_FIELD_SKYPE ,
$conf -> global -> LDAP_FIELD_MAIL ,
$conf -> global -> LDAP_FIELD_TITLE ,
$conf -> global -> LDAP_FIELD_DESCRIPTION ,
$conf -> global -> LDAP_FIELD_SID
);
$ldap = new Ldap ();
$result = $ldap -> connect_bind ();
if ( $result >= 0 ) {
// Remove from required_fields all entries not configured in LDAP (empty) and duplicated
$required_fields = array_unique ( array_values ( array_filter ( $required_fields , " dol_validElement " )));
$ldapusers = $ldap -> getRecords ( $selecteduser , $conf -> global -> LDAP_USER_DN , $conf -> global -> LDAP_KEY_USERS , $required_fields );
//print_r($ldapusers);
if ( is_array ( $ldapusers )) {
foreach ( $ldapusers as $key => $attribute ) {
$ldap_lastname = $attribute [ $conf -> global -> LDAP_FIELD_NAME ];
$ldap_firstname = $attribute [ $conf -> global -> LDAP_FIELD_FIRSTNAME ];
$ldap_login = $attribute [ $conf -> global -> LDAP_FIELD_LOGIN ];
$ldap_loginsmb = $attribute [ $conf -> global -> LDAP_FIELD_LOGIN_SAMBA ];
$ldap_pass = $attribute [ $conf -> global -> LDAP_FIELD_PASSWORD ];
$ldap_pass_crypted = $attribute [ $conf -> global -> LDAP_FIELD_PASSWORD_CRYPTED ];
$ldap_phone = $attribute [ $conf -> global -> LDAP_FIELD_PHONE ];
$ldap_fax = $attribute [ $conf -> global -> LDAP_FIELD_FAX ];
$ldap_mobile = $attribute [ $conf -> global -> LDAP_FIELD_MOBILE ];
2019-09-12 20:03:28 +02:00
$ldap_social [ 'skype' ] = $attribute [ $conf -> global -> LDAP_FIELD_SKYPE ];
$ldap_social [ 'twitter' ] = $attribute [ $conf -> global -> LDAP_FIELD_TWITTER ];
$ldap_social [ 'facebook' ] = $attribute [ $conf -> global -> LDAP_FIELD_FACEBOOK ];
$ldap_social [ 'linkedin' ] = $attribute [ $conf -> global -> LDAP_FIELD_LINKEDIN ];
2017-10-07 13:09:31 +02:00
$ldap_mail = $attribute [ $conf -> global -> LDAP_FIELD_MAIL ];
$ldap_sid = $attribute [ $conf -> global -> LDAP_FIELD_SID ];
}
}
2020-05-21 15:05:19 +02:00
} else {
2017-10-07 13:09:31 +02:00
setEventMessages ( $ldap -> error , $ldap -> errors , 'errors' );
}
}
// Actions to send emails
2019-12-02 09:38:16 +01:00
$triggersendname = 'USER_SENTBYMAIL' ;
2019-11-08 10:53:31 +01:00
$paramname = 'id' ; // Name of param key to open the card
$mode = 'emailfromuser' ;
$trackid = 'use' . $id ;
2017-10-07 13:09:31 +02:00
include DOL_DOCUMENT_ROOT . '/core/actions_sendmails.inc.php' ;
// Actions to build doc
$upload_dir = $conf -> user -> dir_output ;
2019-11-08 10:53:31 +01:00
$permissiontoadd = $user -> rights -> user -> user -> creer ;
2017-10-07 13:09:31 +02:00
include DOL_DOCUMENT_ROOT . '/core/actions_builddoc.inc.php' ;
2006-11-26 01:24:10 +01:00
}
2004-06-09 12:39:40 +02:00
2006-11-19 17:02:53 +01:00
/*
2011-11-02 14:14:46 +01:00
* View
2006-11-19 17:02:53 +01:00
*/
2006-08-31 01:19:35 +02:00
2011-11-08 10:18:45 +01:00
$form = new Form ( $db );
2019-11-08 10:53:31 +01:00
$formother = new FormOther ( $db );
2015-11-18 06:34:08 +01:00
$formcompany = new FormCompany ( $db );
2020-08-07 14:22:43 +02:00
$formadmin = new FormAdmin ( $db );
2017-01-06 16:44:09 +01:00
$formfile = new FormFile ( $db );
2021-02-26 13:18:40 +01:00
if ( ! empty ( $conf -> stock -> enabled )) {
$formproduct = new FormProduct ( $db );
}
2006-08-31 01:19:35 +02:00
2019-01-27 11:55:16 +01:00
llxHeader ( '' , $langs -> trans ( " UserCard " ));
2013-09-06 12:10:09 +02:00
2021-02-26 13:18:40 +01:00
if ( $action == 'create' || $action == 'adduserldap' ) {
2019-10-02 18:36:36 +02:00
print load_fiche_titre ( $langs -> trans ( " NewUser " ), '' , 'user' );
2011-06-29 12:23:32 +02:00
2019-10-02 18:36:36 +02:00
print '<span class="opacitymedium">' . $langs -> trans ( " CreateInternalUserDesc " ) . " </span><br> \n " ;
2017-10-07 13:09:31 +02:00
print " <br> " ;
2011-06-29 12:23:32 +02:00
2015-05-04 11:41:30 +02:00
2021-11-03 22:56:15 +01:00
if ( ! empty ( $conf -> ldap -> enabled ) && ( isset ( $conf -> global -> LDAP_SYNCHRO_ACTIVE ) && getDolGlobalInt ( 'LDAP_SYNCHRO_ACTIVE' ) === Ldap :: SYNCHRO_LDAP_TO_DOLIBARR )) {
2020-11-05 22:25:14 +01:00
// Show form to add an account from LDAP if sync LDAP -> Dolibarr is set
2017-10-07 13:09:31 +02:00
$ldap = new Ldap ();
$result = $ldap -> connect_bind ();
2021-02-26 13:18:40 +01:00
if ( $result >= 0 ) {
2019-11-08 10:53:31 +01:00
$required_fields = array (
2012-10-24 21:19:10 +02:00
$conf -> global -> LDAP_KEY_USERS ,
2017-10-07 13:09:31 +02:00
$conf -> global -> LDAP_FIELD_FULLNAME ,
2012-10-24 21:19:10 +02:00
$conf -> global -> LDAP_FIELD_NAME ,
$conf -> global -> LDAP_FIELD_FIRSTNAME ,
$conf -> global -> LDAP_FIELD_LOGIN ,
$conf -> global -> LDAP_FIELD_LOGIN_SAMBA ,
$conf -> global -> LDAP_FIELD_PASSWORD ,
$conf -> global -> LDAP_FIELD_PASSWORD_CRYPTED ,
2014-09-13 17:41:26 +02:00
$conf -> global -> LDAP_FIELD_PHONE ,
2012-10-24 21:19:10 +02:00
$conf -> global -> LDAP_FIELD_FAX ,
$conf -> global -> LDAP_FIELD_MOBILE ,
2013-11-07 13:17:08 +01:00
$conf -> global -> LDAP_FIELD_SKYPE ,
2012-10-24 21:19:10 +02:00
$conf -> global -> LDAP_FIELD_MAIL ,
$conf -> global -> LDAP_FIELD_TITLE ,
$conf -> global -> LDAP_FIELD_DESCRIPTION ,
2017-10-07 13:09:31 +02:00
$conf -> global -> LDAP_FIELD_SID
);
2011-06-29 12:23:32 +02:00
2017-10-07 13:09:31 +02:00
// Remove from required_fields all entries not configured in LDAP (empty) and duplicated
2019-11-08 10:53:31 +01:00
$required_fields = array_unique ( array_values ( array_filter ( $required_fields , " dol_validElement " )));
2011-06-29 12:23:32 +02:00
2017-10-07 13:09:31 +02:00
// Get from LDAP database an array of results
$ldapusers = $ldap -> getRecords ( '*' , $conf -> global -> LDAP_USER_DN , $conf -> global -> LDAP_KEY_USERS , $required_fields , 1 );
2012-10-24 17:35:28 +02:00
2021-02-26 13:18:40 +01:00
if ( is_array ( $ldapusers )) {
2019-11-08 10:53:31 +01:00
$liste = array ();
2021-02-26 13:18:40 +01:00
foreach ( $ldapusers as $key => $ldapuser ) {
2017-10-07 13:09:31 +02:00
// Define the label string for this user
2019-11-08 10:53:31 +01:00
$label = '' ;
2021-02-26 13:18:40 +01:00
foreach ( $required_fields as $value ) {
if ( $value === $conf -> global -> LDAP_FIELD_PASSWORD || $value === $conf -> global -> LDAP_FIELD_PASSWORD_CRYPTED ) {
$label .= $value . " =******* " ;
} elseif ( $value ) {
$label .= $value . " = " . $ldapuser [ $value ] . " " ;
}
2017-10-07 13:09:31 +02:00
}
$liste [ $key ] = $label ;
}
2020-05-21 15:05:19 +02:00
} else {
2017-10-07 13:09:31 +02:00
setEventMessages ( $ldap -> error , $ldap -> errors , 'errors' );
}
2020-05-21 15:05:19 +02:00
} else {
2017-10-07 13:09:31 +02:00
setEventMessages ( $ldap -> error , $ldap -> errors , 'errors' );
}
// If user list is full, we show drop-down list
2021-02-26 13:18:40 +01:00
print " \n \n <!-- Form liste LDAP debut --> \n " ;
print '<form name="add_user_ldap" action="' . $_SERVER [ " PHP_SELF " ] . '" method="post">' ;
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
print '<table class="border centpercent"><tr>' ;
print '<td width="160">' ;
print $langs -> trans ( " LDAPUsers " );
print '</td>' ;
print '<td>' ;
print '<input type="hidden" name="action" value="adduserldap">' ;
if ( is_array ( $liste ) && count ( $liste )) {
2021-01-14 13:26:54 +01:00
print $form -> selectarray ( 'users' , $liste , '' , 1 , 0 , 0 , '' , 0 , 0 , 0 , '' , 'maxwidth500' );
2017-10-07 13:09:31 +02:00
print ajax_combobox ( 'users' );
}
2021-02-26 13:18:40 +01:00
print '</td><td class="center">' ;
print '<input type="submit" class="button" value="' . dol_escape_htmltag ( $langs -> trans ( 'Get' )) . '"' . ( count ( $liste ) ? '' : ' disabled' ) . '>' ;
print '</td></tr></table>' ;
print '</form>' ;
2017-10-07 13:09:31 +02:00
2021-02-26 13:18:40 +01:00
print " \n <!-- Form liste LDAP fin --> \n \n " ;
print '<br>' ;
2017-10-07 13:09:31 +02:00
}
print '<form action="' . $_SERVER [ 'PHP_SELF' ] . '" method="POST" name="createuser">' ;
2019-12-01 10:20:11 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2017-10-07 13:09:31 +02:00
print '<input type="hidden" name="action" value="add">' ;
2021-02-26 13:18:40 +01:00
if ( ! empty ( $ldap_sid )) {
print '<input type="hidden" name="ldap_sid" value="' . dol_escape_htmltag ( $ldap_sid ) . '">' ;
}
2017-10-07 13:09:31 +02:00
print '<input type="hidden" name="entity" value="' . $conf -> entity . '">' ;
2020-10-22 22:50:03 +02:00
print dol_get_fiche_head ( '' , '' , '' , 0 , '' );
2017-10-07 13:09:31 +02:00
2021-10-31 22:20:02 +01:00
dol_set_focus ( '#lastname' );
2017-10-07 13:09:31 +02:00
print '<table class="border centpercent">' ;
2020-12-05 11:30:18 +01:00
// Civility
print '<tr><td><label for="civility_code">' . $langs -> trans ( " UserTitle " ) . '</label></td><td colspan="3">' ;
print $formcompany -> select_civility ( GETPOSTISSET ( " civility_code " ) ? GETPOST ( " civility_code " , 'aZ09' ) : $object -> civility_code , 'civility_code' );
print '</td></tr>' ;
2017-10-07 13:09:31 +02:00
// Lastname
print '<tr>' ;
print '<td class="titlefieldcreate"><span class="fieldrequired">' . $langs -> trans ( " Lastname " ) . '</span></td>' ;
print '<td>' ;
2021-02-26 13:18:40 +01:00
if ( ! empty ( $ldap_lastname )) {
2019-11-14 17:00:02 +01:00
print '<input type="hidden" id="lastname" name="lastname" value="' . dol_escape_htmltag ( $ldap_lastname ) . '">' ;
2017-10-07 13:09:31 +02:00
print $ldap_lastname ;
2020-05-21 15:05:19 +02:00
} else {
2021-12-12 23:47:40 +01:00
print '<input class="minwidth100 maxwidth150onsmartphone" type="text" id="lastname" name="lastname" value="' . dol_escape_htmltag ( GETPOST ( 'lastname' , 'alphanohtml' )) . '">' ;
2017-10-07 13:09:31 +02:00
}
print '</td></tr>' ;
// Firstname
print '<tr><td>' . $langs -> trans ( " Firstname " ) . '</td>' ;
print '<td>' ;
2021-02-26 13:18:40 +01:00
if ( ! empty ( $ldap_firstname )) {
2019-11-14 17:00:02 +01:00
print '<input type="hidden" name="firstname" value="' . dol_escape_htmltag ( $ldap_firstname ) . '">' ;
2017-10-07 13:09:31 +02:00
print $ldap_firstname ;
2020-05-21 15:05:19 +02:00
} else {
2021-12-12 23:47:40 +01:00
print '<input class="minwidth100 maxwidth150onsmartphone" type="text" name="firstname" value="' . dol_escape_htmltag ( GETPOST ( 'firstname' , 'alphanohtml' )) . '">' ;
2017-10-07 13:09:31 +02:00
}
print '</td></tr>' ;
2015-10-09 07:30:48 +02:00
2017-10-07 13:09:31 +02:00
// Login
print '<tr><td><span class="fieldrequired">' . $langs -> trans ( " Login " ) . '</span></td>' ;
print '<td>' ;
2021-02-26 13:18:40 +01:00
if ( ! empty ( $ldap_login )) {
2019-11-14 17:00:02 +01:00
print '<input type="hidden" name="login" value="' . dol_escape_htmltag ( $ldap_login ) . '">' ;
2017-10-07 13:09:31 +02:00
print $ldap_login ;
2021-02-26 13:18:40 +01:00
} elseif ( ! empty ( $ldap_loginsmb )) {
2019-11-14 17:00:02 +01:00
print '<input type="hidden" name="login" value="' . dol_escape_htmltag ( $ldap_loginsmb ) . '">' ;
2017-10-07 13:09:31 +02:00
print $ldap_loginsmb ;
2020-05-21 15:05:19 +02:00
} else {
2021-12-12 23:47:40 +01:00
print '<input class="maxwidth200 maxwidth150onsmartphone" maxsize="24" type="text" name="login" value="' . dol_escape_htmltag ( GETPOST ( 'login' , 'alphanohtml' )) . '">' ;
2017-10-07 13:09:31 +02:00
}
print '</td></tr>' ;
2019-11-08 10:53:31 +01:00
$generated_password = '' ;
2021-02-26 13:18:40 +01:00
if ( empty ( $ldap_sid )) { // ldap_sid is for activedirectory
2019-11-08 10:53:31 +01:00
$generated_password = getRandomPassword ( false );
2017-10-07 13:09:31 +02:00
}
2020-04-10 10:59:32 +02:00
$password = ( GETPOSTISSET ( 'password' ) ? GETPOST ( 'password' ) : $generated_password );
2017-10-07 13:09:31 +02:00
// Administrator
2021-02-26 13:18:40 +01:00
if ( ! empty ( $user -> admin )) {
2017-10-07 13:09:31 +02:00
print '<tr><td>' . $langs -> trans ( " Administrator " ) . '</td>' ;
print '<td>' ;
2019-01-27 11:55:16 +01:00
print $form -> selectyesno ( 'admin' , GETPOST ( 'admin' ), 1 );
2017-10-07 13:09:31 +02:00
2021-02-26 13:18:40 +01:00
if ( ! empty ( $conf -> multicompany -> enabled ) && ! $user -> entity ) {
if ( ! empty ( $conf -> use_javascript_ajax )) {
2017-10-07 13:09:31 +02:00
print ' < script type = " text/javascript " >
2015-07-19 22:43:06 +02:00
$ ( function () {
$ ( " select[name=admin] " ) . change ( function () {
if ( $ ( this ) . val () == 0 ) {
$ ( " input[name=superadmin] " )
. prop ( " disabled " , true )
. prop ( " checked " , false );
$ ( " select[name=entity] " )
. prop ( " disabled " , false );
} else {
$ ( " input[name=superadmin] " )
. prop ( " disabled " , false );
}
2015-06-15 14:38:02 +02:00
});
2015-07-19 22:43:06 +02:00
$ ( " input[name=superadmin] " ) . change ( function () {
if ( $ ( this ) . is ( " :checked " ) ) {
$ ( " select[name=entity] " )
. prop ( " disabled " , true );
} else {
$ ( " select[name=entity] " )
. prop ( " disabled " , false );
}
});
});
</ script > ' ;
2017-10-07 13:09:31 +02:00
}
2019-11-08 10:53:31 +01:00
$checked = ( GETPOST ( 'superadmin' , 'int' ) ? ' checked' : '' );
$disabled = ( GETPOST ( 'superadmin' , 'int' ) ? '' : ' disabled' );
2021-03-17 22:01:25 +01:00
print '<input type="checkbox" name="superadmin" id="superadmin" value="1"' . $checked . $disabled . ' /> <label for="superadmin">' . $langs -> trans ( " SuperAdministrator " ) . '</span>' ;
2017-10-07 13:09:31 +02:00
}
print " </td></tr> \n " ;
}
2017-12-19 16:16:31 +01:00
// Gender
print '<tr><td>' . $langs -> trans ( " Gender " ) . '</td>' ;
print '<td>' ;
2020-09-15 10:51:09 +02:00
$arraygender = array ( 'man' => $langs -> trans ( " Genderman " ), 'woman' => $langs -> trans ( " Genderwoman " ), 'other' => $langs -> trans ( " Genderother " ));
2017-12-19 16:16:31 +01:00
print $form -> selectarray ( 'gender' , $arraygender , GETPOST ( 'gender' ), 1 );
print '</td></tr>' ;
// Employee
2021-04-25 15:09:56 +02:00
$defaultemployee = '1' ;
2017-12-19 16:16:31 +01:00
print '<tr>' ;
print '<td>' . $langs -> trans ( 'Employee' ) . '</td><td>' ;
2021-04-25 15:09:56 +02:00
print '<input type="checkbox" name="employee" value="1"' . ( GETPOST ( 'employee' ) == '1' ? ' checked="checked"' : ( $defaultemployee ? ' checked="checked"' : '' )) . '>' ;
//print $form->selectyesno("employee", (GETPOST('employee') != '' ?GETPOST('employee') : $defaultemployee), 1);
2017-12-19 16:16:31 +01:00
print '</td></tr>' ;
// Hierarchy
print '<tr><td class="titlefieldcreate">' . $langs -> trans ( " HierarchicalResponsible " ) . '</td>' ;
print '<td>' ;
2021-12-12 23:47:40 +01:00
print img_picto ( '' , 'user' , 'class="pictofixedwidth"' ) . $form -> select_dolusers ( $object -> fk_user , 'fk_user' , 1 , array ( $object -> id ), 0 , '' , 0 , $conf -> entity , 0 , 0 , '' , 0 , '' , 'maxwidth300 widthcentpercentminusx' );
2017-12-19 16:16:31 +01:00
print '</td>' ;
print " </tr> \n " ;
2019-10-02 08:43:40 +02:00
// Expense report validator
2021-02-26 13:18:40 +01:00
if ( ! empty ( $conf -> expensereport -> enabled )) {
2019-10-05 22:22:55 +02:00
print '<tr><td class="titlefieldcreate">' ;
2019-10-07 13:46:13 +02:00
$text = $langs -> trans ( " ForceUserExpenseValidator " );
2019-10-05 22:22:55 +02:00
print $form -> textwithpicto ( $text , $langs -> trans ( " ValidatorIsSupervisorByDefault " ), 1 , 'help' );
print '</td>' ;
2019-10-02 08:43:40 +02:00
print '<td>' ;
2021-12-12 23:47:40 +01:00
print img_picto ( '' , 'user' , 'class="pictofixedwidth"' ) . $form -> select_dolusers ( $object -> fk_user_expense_validator , 'fk_user_expense_validator' , 1 , array ( $object -> id ), 0 , '' , 0 , $conf -> entity , 0 , 0 , '' , 0 , '' , 'maxwidth300 widthcentpercentminusx' );
2019-10-02 08:43:40 +02:00
print '</td>' ;
print " </tr> \n " ;
}
// Holiday request validator
2021-02-26 13:18:40 +01:00
if ( ! empty ( $conf -> holiday -> enabled )) {
2019-10-05 22:22:55 +02:00
print '<tr><td class="titlefieldcreate">' ;
2019-10-07 13:46:13 +02:00
$text = $langs -> trans ( " ForceUserHolidayValidator " );
2019-10-05 22:22:55 +02:00
print $form -> textwithpicto ( $text , $langs -> trans ( " ValidatorIsSupervisorByDefault " ), 1 , 'help' );
print '</td>' ;
2019-10-02 08:43:40 +02:00
print '<td>' ;
2021-12-12 23:47:40 +01:00
print img_picto ( '' , 'user' , 'class="pictofixedwidth"' ) . $form -> select_dolusers ( $object -> fk_user_holiday_validator , 'fk_user_holiday_validator' , 1 , array ( $object -> id ), 0 , '' , 0 , $conf -> entity , 0 , 0 , '' , 0 , '' , 'maxwidth300 widthcentpercentminusx' );
2019-10-02 08:43:40 +02:00
print '</td>' ;
print " </tr> \n " ;
}
2020-12-07 14:25:49 +01:00
// External user
print '<tr><td>' . $langs -> trans ( " ExternalUser " ) . ' ?</td>' ;
print '<td>' ;
print $form -> textwithpicto ( $langs -> trans ( " Internal " ), $langs -> trans ( " InternalExternalDesc " ), 1 , 'help' , '' , 0 , 2 );
print '</td></tr>' ;
2017-12-19 16:16:31 +01:00
2021-04-25 15:09:56 +02:00
print '</table><hr><table class="border centpercent">' ;
// Date validity
print '<tr><td class="titlefieldcreate">' . $langs -> trans ( " RangeOfLoginValidity " ) . '</td>' ;
print '<td>' ;
print $form -> selectDate ( $datestartvalidity , 'datestartvalidity' , 0 , 0 , 1 , 'formdatestartvalidity' , 1 , 1 );
print ' ' ;
print $form -> selectDate ( $dateendvalidity , 'dateendvalidity' , 0 , 0 , 1 , 'formdateendvalidity' , 1 , 0 );
print '</td>' ;
print " </tr> \n " ;
// Password
print '<tr><td class="fieldrequired">' . $langs -> trans ( " Password " ) . '</td>' ;
print '<td>' ;
$valuetoshow = '' ;
if ( preg_match ( '/ldap/' , $dolibarr_main_authentication )) {
$valuetoshow .= ( $valuetoshow ? ', ' : '' ) . $langs -> trans ( " PasswordOfUserInLDAP " );
}
if ( preg_match ( '/http/' , $dolibarr_main_authentication )) {
$valuetoshow .= ( $valuetoshow ? ', ' : '' ) . $langs -> trans ( " HTTPBasicPassword " );
}
if ( preg_match ( '/dolibarr/' , $dolibarr_main_authentication )) {
if ( ! empty ( $ldap_pass )) { // For very old system comaptibilty. Now clear password can't be viewed from LDAP read
$valuetoshow .= ( $valuetoshow ? ', ' : '' ) . '<input type="hidden" name="password" value="' . $ldap_pass . '">' ; // Dolibarr password is preffiled with LDAP known password
$valuetoshow .= preg_replace ( '/./i' , '*' , $ldap_pass );
} else {
// We do not use a field password but a field text to show new password to use.
2021-12-12 23:47:40 +01:00
$valuetoshow .= ( $valuetoshow ? ', ' : '' ) . '<input maxsize="32" type="text" name="password" value="' . $password . '" autocomplete="new-password">' ;
2021-04-25 15:09:56 +02:00
}
}
// Other form for user password
$parameters = array ( 'valuetoshow' => $valuetoshow , 'password' => $password );
$reshook = $hookmanager -> executeHooks ( 'printUserPasswordField' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
if ( $reshook > 0 ) {
$valuetoshow = $hookmanager -> resPrint ; // to replace
} else {
$valuetoshow .= $hookmanager -> resPrint ; // to add
}
print $valuetoshow ;
print '</td></tr>' ;
if ( ! empty ( $conf -> api -> enabled )) {
// API key
//$generated_password = getRandomPassword(false);
print '<tr><td>' . $langs -> trans ( " ApiKey " ) . '</td>' ;
print '<td>' ;
2021-12-12 23:47:40 +01:00
print '<input class="minwidth300 widthcentpercentminusx" maxsize="32" type="text" id="api_key" name="api_key" value="' . GETPOST ( 'api_key' , 'alphanohtml' ) . '" autocomplete="off">' ;
2021-04-25 15:09:56 +02:00
if ( ! empty ( $conf -> use_javascript_ajax )) {
print ' ' . img_picto ( $langs -> trans ( 'Generate' ), 'refresh' , 'id="generate_api_key" class="linkobject"' );
}
print '</td></tr>' ;
} else {
// PARTIAL WORKAROUND
$generated_fake_api_key = getRandomPassword ( false );
print '<input type="hidden" name="api_key" value="' . $generated_fake_api_key . '">' ;
}
2017-12-19 16:16:31 +01:00
print '</table><hr><table class="border centpercent">' ;
2017-10-07 13:09:31 +02:00
// Address
2018-10-27 17:45:29 +02:00
print '<tr><td class="tdtop titlefieldcreate">' . $form -> editfieldkey ( 'Address' , 'address' , '' , $object , 0 ) . '</td>' ;
2016-06-19 16:07:34 +02:00
print '<td><textarea name="address" id="address" class="quatrevingtpercent" rows="3" wrap="soft">' ;
2017-10-07 13:09:31 +02:00
print $object -> address ;
print '</textarea></td></tr>' ;
2015-11-18 06:34:08 +01:00
2017-10-07 13:09:31 +02:00
// Zip
2018-10-27 17:45:29 +02:00
print '<tr><td>' . $form -> editfieldkey ( 'Zip' , 'zipcode' , '' , $object , 0 ) . '</td><td>' ;
2019-11-08 10:53:31 +01:00
print $formcompany -> select_ziptown ( $object -> zip , 'zipcode' , array ( 'town' , 'selectcountry_id' , 'state_id' ), 6 );
2017-10-07 13:09:31 +02:00
print '</td></tr>' ;
2015-11-18 06:34:08 +01:00
// Town
2018-10-27 17:45:29 +02:00
print '<tr><td>' . $form -> editfieldkey ( 'Town' , 'town' , '' , $object , 0 ) . '</td><td>' ;
2019-11-08 10:53:31 +01:00
print $formcompany -> select_ziptown ( $object -> town , 'town' , array ( 'zipcode' , 'selectcountry_id' , 'state_id' ));
2017-10-07 13:09:31 +02:00
print '</td></tr>' ;
// Country
2018-10-27 17:45:29 +02:00
print '<tr><td>' . $form -> editfieldkey ( 'Country' , 'selectcountry_id' , '' , $object , 0 ) . '</td><td class="maxwidthonsmartphone">' ;
2021-12-12 23:47:40 +01:00
print img_picto ( '' , 'country' , 'class="pictofixedwidth"' );
2019-11-08 10:53:31 +01:00
print $form -> select_country (( GETPOST ( 'country_id' ) != '' ? GETPOST ( 'country_id' ) : $object -> country_id ));
2021-02-26 13:18:40 +01:00
if ( $user -> admin ) {
print info_admin ( $langs -> trans ( " YouCanChangeValuesForThisListFromDictionarySetup " ), 1 );
}
2017-10-07 13:09:31 +02:00
print '</td></tr>' ;
// State
2021-02-26 13:18:40 +01:00
if ( empty ( $conf -> global -> USER_DISABLE_STATE )) {
2018-10-27 17:45:29 +02:00
print '<tr><td>' . $form -> editfieldkey ( 'State' , 'state_id' , '' , $object , 0 ) . '</td><td class="maxwidthonsmartphone">' ;
2021-07-04 19:23:04 +02:00
print img_picto ( '' , 'state' , 'class="pictofixedwidth"' );
2019-01-27 11:55:16 +01:00
print $formcompany -> select_state ( $object -> state_id , $object -> country_code , 'state_id' );
2017-10-07 13:09:31 +02:00
print '</td></tr>' ;
}
// Tel
2020-11-24 16:54:13 +01:00
print '<tr><td>' . $langs -> trans ( " PhonePro " ) . '</td>' ;
2017-10-07 13:09:31 +02:00
print '<td>' ;
2021-12-12 23:47:40 +01:00
print img_picto ( '' , 'object_phoning' , 'class="pictofixedwidth"' );
2021-02-26 13:18:40 +01:00
if ( ! empty ( $ldap_phone )) {
2019-11-14 17:00:02 +01:00
print '<input type="hidden" name="office_phone" value="' . dol_escape_htmltag ( $ldap_phone ) . '">' ;
2017-10-07 13:09:31 +02:00
print $ldap_phone ;
2020-05-21 15:05:19 +02:00
} else {
2021-12-12 23:47:40 +01:00
print '<input class="maxwidth200 widthcentpercentminusx" type="text" name="office_phone" value="' . dol_escape_htmltag ( GETPOST ( 'office_phone' , 'alphanohtml' )) . '">' ;
2017-10-07 13:09:31 +02:00
}
print '</td></tr>' ;
// Tel portable
2020-11-24 16:54:13 +01:00
print '<tr><td>' . $langs -> trans ( " PhoneMobile " ) . '</td>' ;
2017-10-07 13:09:31 +02:00
print '<td>' ;
2021-12-12 23:47:40 +01:00
print img_picto ( '' , 'object_phoning_mobile' , 'class="pictofixedwidth"' );
2021-02-26 13:18:40 +01:00
if ( ! empty ( $ldap_mobile )) {
2019-11-14 17:00:02 +01:00
print '<input type="hidden" name="user_mobile" value="' . dol_escape_htmltag ( $ldap_mobile ) . '">' ;
2017-10-07 13:09:31 +02:00
print $ldap_mobile ;
2020-05-21 15:05:19 +02:00
} else {
2021-12-12 23:47:40 +01:00
print '<input class="maxwidth200 widthcentpercentminusx" type="text" name="user_mobile" value="' . dol_escape_htmltag ( GETPOST ( 'user_mobile' , 'alphanohtml' )) . '">' ;
2017-10-07 13:09:31 +02:00
}
print '</td></tr>' ;
// Fax
2020-11-24 16:54:13 +01:00
print '<tr><td>' . $langs -> trans ( " Fax " ) . '</td>' ;
2017-10-07 13:09:31 +02:00
print '<td>' ;
2021-12-12 23:47:40 +01:00
print img_picto ( '' , 'object_phoning_fax' , 'class="pictofixedwidth"' );
2021-02-26 13:18:40 +01:00
if ( ! empty ( $ldap_fax )) {
2019-11-14 17:00:02 +01:00
print '<input type="hidden" name="office_fax" value="' . dol_escape_htmltag ( $ldap_fax ) . '">' ;
2017-10-07 13:09:31 +02:00
print $ldap_fax ;
2020-05-21 15:05:19 +02:00
} else {
2021-12-12 23:47:40 +01:00
print '<input class="maxwidth200 widthcentpercentminusx" type="text" name="office_fax" value="' . dol_escape_htmltag ( GETPOST ( 'office_fax' , 'alphanohtml' )) . '">' ;
2017-10-07 13:09:31 +02:00
}
print '</td></tr>' ;
2019-10-23 21:27:29 +02:00
// EMail
2020-11-24 16:54:13 +01:00
print '<tr><td' . ( ! empty ( $conf -> global -> USER_MAIL_REQUIRED ) ? ' class="fieldrequired"' : '' ) . '>' . $langs -> trans ( " EMail " ) . '</td>' ;
2019-10-23 21:27:29 +02:00
print '<td>' ;
2021-12-12 23:47:40 +01:00
print img_picto ( '' , 'object_email' , 'class="pictofixedwidth"' );
2021-02-26 13:18:40 +01:00
if ( ! empty ( $ldap_mail )) {
2019-11-14 17:00:02 +01:00
print '<input type="hidden" name="email" value="' . dol_escape_htmltag ( $ldap_mail ) . '">' ;
2019-10-23 21:27:29 +02:00
print $ldap_mail ;
2020-05-21 15:05:19 +02:00
} else {
2020-11-24 16:54:13 +01:00
print '<input type="text" name="email" class="maxwidth500 widthcentpercentminusx" value="' . dol_escape_htmltag ( GETPOST ( 'email' , 'alphanohtml' )) . '">' ;
2019-10-23 21:27:29 +02:00
}
print '</td></tr>' ;
2021-12-12 23:47:40 +01:00
// Social networks
2019-11-08 10:53:31 +01:00
if ( ! empty ( $conf -> socialnetworks -> enabled )) {
2019-09-12 20:03:28 +02:00
foreach ( $socialnetworks as $key => $value ) {
2019-09-14 12:00:39 +02:00
if ( $value [ 'active' ]) {
print '<tr><td>' . $langs -> trans ( $value [ 'label' ]) . '</td>' ;
print '<td>' ;
2021-03-12 15:34:31 +01:00
if ( ! empty ( $value [ 'icon' ])) {
2021-12-12 23:47:40 +01:00
print '<span class="fa ' . $value [ 'icon' ] . ' pictofixedwidth"></span>' ;
2021-03-12 15:34:31 +01:00
}
2019-11-08 10:53:31 +01:00
if ( ! empty ( $ldap_social [ $key ])) {
2019-09-14 12:00:39 +02:00
print '<input type="hidden" name="' . $key . '" value="' . $ldap_social [ $key ] . '">' ;
print $ldap_social [ $key ];
} else {
2021-12-12 23:47:40 +01:00
print '<input class="maxwidth200 widthcentpercentminusx" type="text" name="' . $key . '" value="' . GETPOST ( $key , 'alphanohtml' ) . '">' ;
2019-09-14 12:00:39 +02:00
}
print '</td></tr>' ;
2019-09-12 20:03:28 +02:00
} else {
2019-09-14 12:00:39 +02:00
// if social network is not active but value exist we do not want to loose it
2019-11-08 10:53:31 +01:00
if ( ! empty ( $ldap_social [ $key ])) {
2019-09-14 12:00:39 +02:00
print '<input type="hidden" name="' . $key . '" value="' . $ldap_social [ $key ] . '">' ;
} else {
print '<input type="hidden" name="' . $key . '" value="' . GETPOST ( $key , 'alphanohtml' ) . '">' ;
}
2019-09-12 20:03:28 +02:00
}
2017-10-07 13:09:31 +02:00
}
}
2019-02-25 09:07:58 +01:00
2017-10-07 13:09:31 +02:00
// Accountancy code
2021-05-18 20:13:26 +02:00
if ( ! empty ( $conf -> accounting -> enabled )) {
2017-10-07 13:09:31 +02:00
print '<tr><td>' . $langs -> trans ( " AccountancyCode " ) . '</td>' ;
print '<td>' ;
2021-12-12 23:47:40 +01:00
print '<input type="text" class="maxwidthonsmartphone" name="accountancy_code" value="' . dol_escape_htmltag ( GETPOST ( 'accountancy_code' , 'alphanohtml' )) . '">' ;
2017-10-07 13:09:31 +02:00
print '</td></tr>' ;
}
2014-10-16 06:20:54 +02:00
// User color
2021-02-26 13:18:40 +01:00
if ( ! empty ( $conf -> agenda -> enabled )) {
2015-05-15 02:34:57 +02:00
print '<tr><td>' . $langs -> trans ( " ColorUser " ) . '</td>' ;
2014-10-16 06:20:54 +02:00
print '<td>' ;
2020-04-10 10:59:32 +02:00
print $formother -> selectColor ( GETPOSTISSET ( 'color' ) ? GETPOST ( 'color' , 'alphanohtml' ) : $object -> color , 'color' , null , 1 , '' , 'hideifnotset' );
2014-10-16 06:20:54 +02:00
print '</td></tr>' ;
}
2017-06-06 07:57:03 +02:00
2016-02-13 10:42:45 +01:00
// Categories
2021-02-26 13:18:40 +01:00
if ( ! empty ( $conf -> categorie -> enabled ) && ! empty ( $user -> rights -> categorie -> lire )) {
2021-12-12 23:47:40 +01:00
print '<tr><td>' . $form -> editfieldkey ( 'Categories' , 'usercats' , '' , $object , 0 ) . '</td><td>' ;
2017-01-16 10:15:57 +01:00
$cate_arbo = $form -> select_all_categories ( 'user' , null , 'parent' , null , null , 1 );
2021-12-12 23:47:40 +01:00
print img_picto ( '' , 'category' , 'class="pictofixedwidth"' ) . $form -> multiselectarray ( 'usercats' , $cate_arbo , GETPOST ( 'usercats' , 'array' ), 0 , 0 , 'maxwdith300 widthcentpercentminusx' , 0 , '90%' );
2016-02-13 10:42:45 +01:00
print " </td></tr> " ;
}
2017-08-25 15:04:55 +02:00
2021-02-26 13:18:40 +01:00
if ( ! empty ( $conf -> global -> MAIN_MULTILANGS )) {
2021-05-27 14:25:00 +02:00
print '<tr><td>' . $form -> editfieldkey ( 'DefaultLang' , 'default_lang' , '' , $object , 0 , 'string' , '' , 0 , 0 , 'id' , $langs -> trans ( " WarningNotLangOfInterface " , $langs -> transnoentitiesnoconv ( " UserGUISetup " ))) . '</td>' ;
2021-12-12 23:47:40 +01:00
print '<td class="maxwidthonsmartphone">' . " \n " ;
print img_picto ( '' , 'language' , 'class="pictofixedwidth"' ) . $formadmin -> select_language ( GETPOST ( 'default_lang' , 'alpha' ) ? GETPOST ( 'default_lang' , 'alpha' ) : ( $object -> lang ? $object -> lang : '' ), 'default_lang' , 0 , 0 , 1 , 0 , 0 , 'maxwidth200onsmartphone widthcentpercentminusx' );
2020-08-07 14:22:43 +02:00
print '</td>' ;
print '</tr>' ;
}
2017-08-25 13:25:34 +02:00
// Multicompany
2021-02-26 13:18:40 +01:00
if ( ! empty ( $conf -> multicompany -> enabled ) && is_object ( $mc )) {
2018-07-05 22:15:55 +02:00
// This is now done with hook formObjectOptions. Keep this code for backward compatibility with old multicompany module
2021-02-26 13:18:40 +01:00
if ( ! method_exists ( $mc , 'formObjectOptions' )) {
if ( empty ( $conf -> global -> MULTICOMPANY_TRANSVERSE_MODE ) && $conf -> entity == 1 && $user -> admin && ! $user -> entity ) { // condition must be same for create and edit mode
print " <tr> " . '<td>' . $langs -> trans ( " Entity " ) . '</td>' ;
2018-07-05 22:15:55 +02:00
print " <td> " . $mc -> select_entities ( $conf -> entity );
print " </td></tr> \n " ;
2020-05-21 15:05:19 +02:00
} else {
2018-07-05 22:15:55 +02:00
print '<input type="hidden" name="entity" value="' . $conf -> entity . '" />' ;
}
2019-02-03 14:29:45 +01:00
}
2018-07-05 22:15:55 +02:00
}
2017-08-25 13:25:34 +02:00
2017-10-07 13:09:31 +02:00
// Other attributes
2021-12-12 23:47:40 +01:00
$parameters = array ();
2020-04-05 03:14:12 +02:00
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_add.tpl.php' ;
2017-10-07 13:09:31 +02:00
// Note
print '<tr><td class="tdtop">' ;
print $langs -> trans ( " Note " );
print '</td><td>' ;
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php' ;
2021-05-18 20:13:26 +02:00
$doleditor = new DolEditor ( 'note' , GETPOSTISSET ( 'note' ) ? GETPOST ( 'note' , 'restricthtml' ) : '' , '' , 120 , 'dolibarr_notes' , '' , false , true , getDolGlobalString ( 'FCKEDITOR_ENABLE_SOCIETE' ), ROWS_3 , '90%' );
2017-10-07 13:09:31 +02:00
$doleditor -> Create ();
print " </td></tr> \n " ;
// Signature
print '<tr><td class="tdtop">' . $langs -> trans ( " Signature " ) . '</td>' ;
2021-04-25 15:27:10 +02:00
print '<td class="wordbreak">' ;
2017-10-07 13:09:31 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php' ;
2020-09-17 16:13:57 +02:00
$doleditor = new DolEditor ( 'signature' , GETPOST ( 'signature' , 'restricthtml' ), '' , 138 , 'dolibarr_notes' , 'In' , true , true , empty ( $conf -> global -> FCKEDITOR_ENABLE_USERSIGN ) ? 0 : 1 , ROWS_4 , '90%' );
2017-10-07 13:09:31 +02:00
print $doleditor -> Create ( 1 );
print '</td></tr>' ;
2017-12-19 16:16:31 +01:00
print '</table><hr><table class="border centpercent">' ;
// TODO Move this into tab RH (HierarchicalResponsible must be on both tab)
2019-02-15 05:24:25 +01:00
// Default warehouse
2021-02-26 13:18:40 +01:00
if ( ! empty ( $conf -> stock -> enabled ) && ! empty ( $conf -> global -> MAIN_DEFAULT_WAREHOUSE_USER )) {
2019-02-15 17:12:39 +01:00
print '<tr><td>' . $langs -> trans ( " DefaultWarehouse " ) . '</td><td>' ;
print $formproduct -> selectWarehouses ( $object -> fk_warehouse , 'fk_warehouse' , 'warehouseopen' , 1 );
print '</td></tr>' ;
}
2017-12-19 16:16:31 +01:00
2019-10-07 13:46:13 +02:00
// Position/Job
print '<tr><td class="titlefieldcreate">' . $langs -> trans ( " PostOrFunction " ) . '</td>' ;
print '<td>' ;
2021-12-12 23:47:40 +01:00
print '<input class="maxwidth200 maxwidth150onsmartphone" type="text" name="job" value="' . dol_escape_htmltag ( GETPOST ( 'job' , 'alphanohtml' )) . '">' ;
2019-10-07 13:46:13 +02:00
print '</td></tr>' ;
2021-06-15 14:18:09 +02:00
if (( ! empty ( $conf -> salaries -> enabled ) && ! empty ( $user -> rights -> salaries -> read ) && in_array ( $id , $childids ))
|| ( ! empty ( $conf -> salaries -> enabled ) && ! empty ( $user -> rights -> salaries -> readall ))
2021-02-26 13:18:40 +01:00
|| ( ! empty ( $conf -> hrm -> enabled ) && ! empty ( $user -> rights -> hrm -> employee -> read ))) {
2017-12-19 16:16:31 +01:00
$langs -> load ( " salaries " );
// THM
print '<tr><td>' ;
2019-11-08 10:53:31 +01:00
$text = $langs -> trans ( " THM " );
2017-12-19 16:16:31 +01:00
print $form -> textwithpicto ( $text , $langs -> trans ( " THMDescription " ), 1 , 'help' , 'classthm' );
print '</td>' ;
print '<td>' ;
2021-03-12 15:34:31 +01:00
print '<input size="8" type="text" name="thm" value="' . dol_escape_htmltag ( GETPOST ( 'thm' )) . '"> ' . $langs -> getCurrencySymbol ( $conf -> currency );
2017-12-19 16:16:31 +01:00
print '</td>' ;
print " </tr> \n " ;
// TJM
print '<tr><td>' ;
2019-11-08 10:53:31 +01:00
$text = $langs -> trans ( " TJM " );
2017-12-19 16:16:31 +01:00
print $form -> textwithpicto ( $text , $langs -> trans ( " TJMDescription " ), 1 , 'help' , 'classtjm' );
print '</td>' ;
print '<td>' ;
2021-03-12 15:34:31 +01:00
print '<input size="8" type="text" name="tjm" value="' . dol_escape_htmltag ( GETPOST ( 'tjm' )) . '"> ' . $langs -> getCurrencySymbol ( $conf -> currency );
2017-12-19 16:16:31 +01:00
print '</td>' ;
print " </tr> \n " ;
// Salary
print '<tr><td>' . $langs -> trans ( " Salary " ) . '</td>' ;
print '<td>' ;
2021-03-12 15:34:31 +01:00
print img_picto ( '' , 'salary' , 'class="pictofixedwidth paddingright"' ) . '<input size="8" type="text" name="salary" value="' . dol_escape_htmltag ( GETPOST ( 'salary' )) . '"> ' . $langs -> getCurrencySymbol ( $conf -> currency );
2017-12-19 16:16:31 +01:00
print '</td>' ;
print " </tr> \n " ;
}
// Weeklyhours
print '<tr><td>' . $langs -> trans ( " WeeklyHours " ) . '</td>' ;
print '<td>' ;
2019-11-14 17:00:02 +01:00
print '<input size="8" type="text" name="weeklyhours" value="' . dol_escape_htmltag ( GETPOST ( 'weeklyhours' )) . '">' ;
2017-12-19 16:16:31 +01:00
print '</td>' ;
print " </tr> \n " ;
// Date employment
print '<tr><td>' . $langs -> trans ( " DateEmployment " ) . '</td>' ;
print '<td>' ;
2020-09-21 18:44:20 +02:00
print $form -> selectDate ( $dateemployment , 'dateemployment' , 0 , 0 , 1 , 'formdateemployment' , 1 , 1 );
print ' - ' ;
print $form -> selectDate ( $dateemploymentend , 'dateemploymentend' , 0 , 0 , 1 , 'formdateemploymentend' , 1 , 0 );
2017-12-19 16:16:31 +01:00
print '</td>' ;
print " </tr> \n " ;
// Date birth
2020-09-21 18:44:20 +02:00
print '<tr><td>' . $langs -> trans ( " DateOfBirth " ) . '</td>' ;
2017-12-19 16:16:31 +01:00
print '<td>' ;
2020-09-21 18:44:20 +02:00
print $form -> selectDate ( $dateofbirth , 'dateofbirth' , 0 , 0 , 1 , 'createuser' , 1 , 0 );
2017-12-19 16:16:31 +01:00
print '</td>' ;
print " </tr> \n " ;
2017-10-07 13:09:31 +02:00
print " </table> \n " ;
2011-11-02 14:14:46 +01:00
2021-02-26 13:18:40 +01:00
print dol_get_fiche_end ();
2015-05-04 11:41:30 +02:00
2021-08-20 14:41:30 +02:00
print $form -> buttonsSaveCancel ( " CreateUser " );
2011-11-02 14:14:46 +01:00
2017-10-07 13:09:31 +02:00
print " </form> " ;
2020-05-21 15:05:19 +02:00
} else {
2020-11-05 22:25:14 +01:00
// View and edit mode
2021-02-26 13:18:40 +01:00
if ( $id > 0 ) {
2021-03-15 00:59:07 +01:00
$res = $object -> fetch ( $id , '' , '' , 1 );
2021-02-26 13:18:40 +01:00
if ( $res < 0 ) {
2021-03-15 00:59:07 +01:00
dol_print_error ( $db , $object -> error );
exit ;
2021-02-26 13:18:40 +01:00
}
2019-11-08 10:53:31 +01:00
$res = $object -> fetch_optionals ();
2017-06-06 07:57:03 +02:00
2016-06-04 13:25:39 +02:00
// Check if user has rights
2021-02-26 13:18:40 +01:00
if ( empty ( $conf -> global -> MULTICOMPANY_TRANSVERSE_MODE )) {
2018-07-04 14:48:00 +02:00
$object -> getrights ();
2021-02-26 13:18:40 +01:00
if ( empty ( $object -> nb_rights ) && $object -> statut != 0 && empty ( $object -> admin )) {
setEventMessages ( $langs -> trans ( 'UserHasNoPermissions' ), null , 'warnings' );
}
2018-07-04 14:48:00 +02:00
}
2018-12-22 17:34:27 +01:00
2017-10-07 13:09:31 +02:00
// Connexion ldap
// pour recuperer passDoNotExpire et userChangePassNextLogon
2021-02-26 13:18:40 +01:00
if ( ! empty ( $conf -> ldap -> enabled ) && ! empty ( $object -> ldap_sid )) {
2017-10-07 13:09:31 +02:00
$ldap = new Ldap ();
2019-11-08 10:53:31 +01:00
$result = $ldap -> connect_bind ();
2021-02-26 13:18:40 +01:00
if ( $result > 0 ) {
2017-10-07 13:09:31 +02:00
$userSearchFilter = '(' . $conf -> global -> LDAP_FILTER_CONNECTION . '(' . $ldap -> getUserIdentifier () . '=' . $object -> login . '))' ;
2019-01-27 11:55:16 +01:00
$entries = $ldap -> fetch ( $object -> login , $userSearchFilter );
2021-02-26 13:18:40 +01:00
if ( ! $entries ) {
2017-10-07 13:09:31 +02:00
setEventMessages ( $ldap -> error , $ldap -> errors , 'errors' );
}
$passDoNotExpire = 0 ;
$userChangePassNextLogon = 0 ;
$userDisabled = 0 ;
$statutUACF = '' ;
// Check options of user account
2021-02-26 13:18:40 +01:00
if ( count ( $ldap -> uacf ) > 0 ) {
foreach ( $ldap -> uacf as $key => $statut ) {
if ( $key == 65536 ) {
2017-10-07 13:09:31 +02:00
$passDoNotExpire = 1 ;
$statutUACF = $statut ;
}
}
2020-05-21 15:05:19 +02:00
} else {
2017-10-07 13:09:31 +02:00
$userDisabled = 1 ;
$statutUACF = " ACCOUNTDISABLE " ;
}
2021-02-26 13:18:40 +01:00
if ( $ldap -> pwdlastset == 0 ) {
2017-10-07 13:09:31 +02:00
$userChangePassNextLogon = 1 ;
}
}
}
2011-06-29 12:23:32 +02:00
2017-10-07 13:09:31 +02:00
// Show tabs
2021-02-26 13:18:40 +01:00
if ( $mode == 'employee' ) { // For HRM module development
2015-11-17 21:22:45 +01:00
$title = $langs -> trans ( " Employee " );
2018-02-07 12:08:25 +01:00
$linkback = '<a href="' . DOL_URL_ROOT . '/hrm/employee/list.php?restore_lastsearch_values=1">' . $langs -> trans ( " BackToList " ) . '</a>' ;
2020-05-21 15:05:19 +02:00
} else {
2015-11-17 21:22:45 +01:00
$title = $langs -> trans ( " User " );
2017-04-09 14:09:33 +02:00
$linkback = '' ;
if ( $user -> rights -> user -> user -> lire || $user -> admin ) {
2018-04-06 00:36:52 +02:00
$linkback = '<a href="' . DOL_URL_ROOT . '/user/list.php?restore_lastsearch_values=1">' . $langs -> trans ( " BackToList " ) . '</a>' ;
2017-04-09 14:09:33 +02:00
}
2015-11-17 21:22:45 +01:00
}
2017-10-07 13:09:31 +02:00
$head = user_prepare_head ( $object );
2011-06-29 12:23:32 +02:00
2017-10-07 13:09:31 +02:00
/*
2021-02-26 13:18:40 +01:00
* Confirmation reinitialisation mot de passe
*/
if ( $action == 'password' ) {
2019-01-27 11:55:16 +01:00
print $form -> formconfirm ( $_SERVER [ 'PHP_SELF' ] . " ?id= $object->id " , $langs -> trans ( " ReinitPassword " ), $langs -> trans ( " ConfirmReinitPassword " , $object -> login ), " confirm_password " , '' , 0 , 1 );
2017-10-07 13:09:31 +02:00
}
2011-06-29 12:23:32 +02:00
2017-10-07 13:09:31 +02:00
/*
2021-02-26 13:18:40 +01:00
* Confirmation envoi mot de passe
*/
if ( $action == 'passwordsend' ) {
2019-01-27 11:55:16 +01:00
print $form -> formconfirm ( $_SERVER [ 'PHP_SELF' ] . " ?id= $object->id " , $langs -> trans ( " SendNewPassword " ), $langs -> trans ( " ConfirmSendNewPassword " , $object -> login ), " confirm_passwordsend " , '' , 0 , 1 );
2017-10-07 13:09:31 +02:00
}
2011-06-29 12:23:32 +02:00
2017-10-07 13:09:31 +02:00
/*
2021-02-26 13:18:40 +01:00
* Confirm deactivation
*/
if ( $action == 'disable' ) {
2019-01-27 11:55:16 +01:00
print $form -> formconfirm ( $_SERVER [ 'PHP_SELF' ] . " ?id= $object->id " , $langs -> trans ( " DisableAUser " ), $langs -> trans ( " ConfirmDisableUser " , $object -> login ), " confirm_disable " , '' , 0 , 1 );
2017-10-07 13:09:31 +02:00
}
2011-06-29 12:23:32 +02:00
2017-10-07 13:09:31 +02:00
/*
2021-02-26 13:18:40 +01:00
* Confirm activation
*/
if ( $action == 'enable' ) {
2019-01-27 11:55:16 +01:00
print $form -> formconfirm ( $_SERVER [ 'PHP_SELF' ] . " ?id= $object->id " , $langs -> trans ( " EnableAUser " ), $langs -> trans ( " ConfirmEnableUser " , $object -> login ), " confirm_enable " , '' , 0 , 1 );
2017-10-07 13:09:31 +02:00
}
2011-06-29 12:23:32 +02:00
2017-10-07 13:09:31 +02:00
/*
2021-02-26 13:18:40 +01:00
* Confirmation suppression
*/
if ( $action == 'delete' ) {
2019-01-27 11:55:16 +01:00
print $form -> formconfirm ( $_SERVER [ 'PHP_SELF' ] . " ?id= $object->id " , $langs -> trans ( " DeleteAUser " ), $langs -> trans ( " ConfirmDeleteUser " , $object -> login ), " confirm_delete " , '' , 0 , 1 );
2017-10-07 13:09:31 +02:00
}
2011-06-29 12:23:32 +02:00
2017-10-07 13:09:31 +02:00
/*
2021-02-26 13:18:40 +01:00
* Fiche en mode visu
*/
if ( $action != 'edit' ) {
2020-10-22 22:50:03 +02:00
print dol_get_fiche_head ( $head , 'user' , $title , - 1 , 'user' );
2015-05-04 11:41:30 +02:00
2019-01-27 11:55:16 +01:00
dol_banner_tab ( $object , 'id' , $linkback , $user -> rights -> user -> user -> lire || $user -> admin );
2015-10-15 16:11:03 +02:00
2017-10-07 13:09:31 +02:00
print '<div class="fichecenter">' ;
print '<div class="fichehalfleft">' ;
2015-10-15 16:11:03 +02:00
2017-10-07 13:09:31 +02:00
print '<div class="underbanner clearboth"></div>' ;
print '<table class="border tableforfield" width="100%">' ;
2015-10-15 16:11:03 +02:00
2017-10-07 13:09:31 +02:00
// Login
2021-04-25 15:09:56 +02:00
print '<tr><td class="titlefieldmiddle">' . $langs -> trans ( " Login " ) . '</td>' ;
2021-02-26 13:18:40 +01:00
if ( ! empty ( $object -> ldap_sid ) && $object -> statut == 0 ) {
2021-10-28 14:28:04 +02:00
print '<td class="error">' ;
print $langs -> trans ( " LoginAccountDisableInDolibarr " );
print '</td>' ;
2020-05-21 15:05:19 +02:00
} else {
2021-10-28 14:28:04 +02:00
print '<td>' ;
$addadmin = '' ;
if ( property_exists ( $object , 'admin' )) {
if ( ! empty ( $conf -> multicompany -> enabled ) && ! empty ( $object -> admin ) && empty ( $object -> entity )) {
$addadmin .= img_picto ( $langs -> trans ( " SuperAdministratorDesc " ), " redstar " , 'class="paddingleft"' );
} elseif ( ! empty ( $object -> admin )) {
$addadmin .= img_picto ( $langs -> trans ( " AdministratorDesc " ), " star " , 'class="paddingleft"' );
}
}
print showValueWithClipboardCPButton ( $object -> login ) . $addadmin ;
print '</td>' ;
2017-10-07 13:09:31 +02:00
}
print '</tr>' . " \n " ;
2008-08-28 14:08:02 +02:00
2017-10-07 13:09:31 +02:00
// Type
print '<tr><td>' ;
2019-11-08 10:53:31 +01:00
$text = $langs -> trans ( " Type " );
2017-10-07 13:09:31 +02:00
print $form -> textwithpicto ( $text , $langs -> trans ( " InternalExternalDesc " ));
print '</td><td>' ;
2019-11-08 10:53:31 +01:00
$type = $langs -> trans ( " Internal " );
2021-02-26 13:18:40 +01:00
if ( $object -> socid > 0 ) {
$type = $langs -> trans ( " External " );
}
2021-07-05 19:28:50 +02:00
print '<span class="badgeneutral">' ;
2015-06-20 19:42:07 +02:00
print $type ;
2021-02-26 13:18:40 +01:00
if ( $object -> ldap_sid ) {
print ' (' . $langs -> trans ( " DomainUser " ) . ')' ;
}
2021-07-05 19:28:50 +02:00
print '</span>' ;
2017-10-07 13:09:31 +02:00
print '</td></tr>' . " \n " ;
2008-08-28 14:08:02 +02:00
2017-10-07 13:09:31 +02:00
// Ldap sid
2021-02-26 13:18:40 +01:00
if ( $object -> ldap_sid ) {
2017-10-07 13:09:31 +02:00
print '<tr><td>' . $langs -> trans ( " Type " ) . '</td><td>' ;
2019-01-27 11:55:16 +01:00
print $langs -> trans ( " DomainUser " , $ldap -> domainFQDN );
2017-10-07 13:09:31 +02:00
print '</td></tr>' . " \n " ;
}
2013-01-02 14:35:16 +01:00
2017-12-19 16:16:31 +01:00
// Employee
2021-07-20 23:54:22 +02:00
print '<tr><td>' . $langs -> trans ( " Employee " ) . '</td><td>' ;
2021-04-25 15:09:56 +02:00
print '<input type="checkbox" disabled name="employee" value="1"' . ( $object -> employee ? ' checked="checked"' : '' ) . '>' ;
//print yn($object->employee);
2017-12-19 16:16:31 +01:00
print '</td></tr>' . " \n " ;
2017-06-06 07:57:03 +02:00
2021-10-28 14:28:04 +02:00
// TODO This is also available into the tab RH
2017-05-19 13:39:00 +02:00
2017-10-07 13:09:31 +02:00
// Hierarchy
print '<tr><td>' . $langs -> trans ( " HierarchicalResponsible " ) . '</td>' ;
print '<td>' ;
2020-04-19 15:52:43 +02:00
if ( empty ( $object -> fk_user )) {
print '<span class="opacitymedium">' . $langs -> trans ( " None " ) . '</span>' ;
2020-05-21 15:05:19 +02:00
} else {
2019-11-08 10:53:31 +01:00
$huser = new User ( $db );
2021-07-08 16:31:01 +02:00
if ( $object -> fk_user > 0 ) {
$huser -> fetch ( $object -> fk_user );
2021-07-07 14:50:10 +02:00
print $huser -> getNomUrl ( 1 );
} else {
print '<span class="opacitymedium">' . $langs -> trans ( " None " ) . '</span>' ;
}
2017-10-07 13:09:31 +02:00
}
print '</td>' ;
print " </tr> \n " ;
2013-09-18 21:22:24 +02:00
2019-10-02 08:43:40 +02:00
// Expense report validator
2020-06-03 23:30:06 +02:00
if ( ! empty ( $conf -> expensereport -> enabled )) {
print '<tr><td>' ;
$text = $langs -> trans ( " ForceUserExpenseValidator " );
print $form -> textwithpicto ( $text , $langs -> trans ( " ValidatorIsSupervisorByDefault " ), 1 , 'help' );
print '</td>' ;
print '<td>' ;
if ( ! empty ( $object -> fk_user_expense_validator )) {
$evuser = new User ( $db );
$evuser -> fetch ( $object -> fk_user_expense_validator );
print $evuser -> getNomUrl ( 1 );
}
print '</td>' ;
print " </tr> \n " ;
2019-10-02 08:43:40 +02:00
}
// Holiday request validator
2020-06-03 23:30:06 +02:00
if ( ! empty ( $conf -> holiday -> enabled )) {
print '<tr><td>' ;
$text = $langs -> trans ( " ForceUserHolidayValidator " );
print $form -> textwithpicto ( $text , $langs -> trans ( " ValidatorIsSupervisorByDefault " ), 1 , 'help' );
print '</td>' ;
print '<td>' ;
if ( ! empty ( $object -> fk_user_holiday_validator )) {
$hvuser = new User ( $db );
$hvuser -> fetch ( $object -> fk_user_holiday_validator );
print $hvuser -> getNomUrl ( 1 );
}
print '</td>' ;
print " </tr> \n " ;
2019-10-02 08:43:40 +02:00
}
2019-02-27 13:48:13 +01:00
2020-09-07 10:18:17 +02:00
// Position/Job
print '<tr><td>' . $langs -> trans ( " PostOrFunction " ) . '</td>' ;
2020-09-19 03:25:25 +02:00
print '<td>' . dol_escape_htmltag ( $object -> job ) . '</td>' ;
2020-09-07 10:18:17 +02:00
print '</tr>' . " \n " ;
2019-10-07 13:46:13 +02:00
2021-10-28 14:28:04 +02:00
// Weeklyhours
print '<tr><td>' . $langs -> trans ( " WeeklyHours " ) . '</td>' ;
print '<td>' ;
print price2num ( $object -> weeklyhours );
print '</td>' ;
print " </tr> \n " ;
// Sensitive salary/value information
if (( empty ( $user -> socid ) && in_array ( $id , $childids )) // A user can always see salary/value information for its subordinates
2021-06-15 14:26:59 +02:00
|| ( ! empty ( $conf -> salaries -> enabled ) && ! empty ( $user -> rights -> salaries -> readall ))
2021-02-26 13:18:40 +01:00
|| ( ! empty ( $conf -> hrm -> enabled ) && ! empty ( $user -> rights -> hrm -> employee -> read ))) {
2017-10-07 13:09:31 +02:00
$langs -> load ( " salaries " );
2021-10-28 14:28:04 +02:00
// Salary
print '<tr><td>' . $langs -> trans ( " Salary " ) . '</td>' ;
print '<td>' ;
print ( $object -> salary != '' ? img_picto ( '' , 'salary' , 'class="pictofixedwidth paddingright"' ) . '<span class="amount">' . price ( $object -> salary , '' , $langs , 1 , - 1 , - 1 , $conf -> currency ) : '' ) . '</span>' ;
print '</td>' ;
print " </tr> \n " ;
2017-10-07 13:09:31 +02:00
// THM
print '<tr><td>' ;
2019-11-08 10:53:31 +01:00
$text = $langs -> trans ( " THM " );
2017-10-07 13:09:31 +02:00
print $form -> textwithpicto ( $text , $langs -> trans ( " THMDescription " ), 1 , 'help' , 'classthm' );
print '</td>' ;
print '<td>' ;
2019-11-08 10:53:31 +01:00
print ( $object -> thm != '' ? price ( $object -> thm , '' , $langs , 1 , - 1 , - 1 , $conf -> currency ) : '' );
2017-10-07 13:09:31 +02:00
print '</td>' ;
print " </tr> \n " ;
// TJM
print '<tr><td>' ;
2019-11-08 10:53:31 +01:00
$text = $langs -> trans ( " TJM " );
2017-10-07 13:09:31 +02:00
print $form -> textwithpicto ( $text , $langs -> trans ( " TJMDescription " ), 1 , 'help' , 'classtjm' );
print '</td>' ;
print '<td>' ;
2019-11-08 10:53:31 +01:00
print ( $object -> tjm != '' ? price ( $object -> tjm , '' , $langs , 1 , - 1 , - 1 , $conf -> currency ) : '' );
2017-10-07 13:09:31 +02:00
print '</td>' ;
print " </tr> \n " ;
}
2014-09-13 17:41:26 +02:00
2017-10-07 13:09:31 +02:00
// Date employment
2020-07-09 14:07:41 +02:00
print '<tr><td>' . $langs -> trans ( " DateOfEmployment " ) . '</td>' ;
2017-10-07 13:09:31 +02:00
print '<td>' ;
2020-07-09 14:07:41 +02:00
if ( $object -> dateemployment ) {
2020-09-21 18:44:20 +02:00
print '<span class="opacitymedium">' . $langs -> trans ( " FromDate " ) . '</span> ' ;
2020-07-09 14:07:41 +02:00
print dol_print_date ( $object -> dateemployment , 'day' );
}
if ( $object -> dateemploymentend ) {
2020-09-21 18:44:20 +02:00
print '<span class="opacitymedium"> - ' . $langs -> trans ( " To " ) . '</span> ' ;
2020-07-09 14:07:41 +02:00
print dol_print_date ( $object -> dateemploymentend , 'day' );
}
2018-05-12 18:05:06 +02:00
print '</td>' ;
print " </tr> \n " ;
2021-10-28 14:28:04 +02:00
// Default warehouse
if ( ! empty ( $conf -> stock -> enabled ) && ! empty ( $conf -> global -> MAIN_DEFAULT_WAREHOUSE_USER )) {
require_once DOL_DOCUMENT_ROOT . '/product/stock/class/entrepot.class.php' ;
print '<tr><td>' . $langs -> trans ( " DefaultWarehouse " ) . '</td><td>' ;
if ( $object -> fk_warehouse > 0 ) {
$warehousestatic = new Entrepot ( $db );
$warehousestatic -> fetch ( $object -> fk_warehouse );
print $warehousestatic -> getNomUrl ( 1 );
}
print '</td></tr>' ;
}
2017-12-19 16:16:31 +01:00
// Accountancy code
2021-05-20 17:40:44 +02:00
if ( ! empty ( $conf -> accounting -> enabled )) {
2017-12-19 16:16:31 +01:00
print '<tr><td>' . $langs -> trans ( " AccountancyCode " ) . '</td>' ;
print '<td>' . $object -> accountancy_code . '</td></tr>' ;
}
2017-10-07 13:09:31 +02:00
print '</table>' ;
2015-10-15 16:11:03 +02:00
2017-10-07 13:09:31 +02:00
print '</div>' ;
2021-10-23 17:18:35 +02:00
print '<div class="fichehalfright">' ;
2015-10-15 16:11:03 +02:00
2017-10-07 13:09:31 +02:00
print '<div class="underbanner clearboth"></div>' ;
2021-04-25 15:09:56 +02:00
2019-02-16 10:29:15 +01:00
print '<table class="border tableforfield centpercent">' ;
2015-10-15 16:11:03 +02:00
2017-10-07 13:09:31 +02:00
// Color user
2021-02-26 13:18:40 +01:00
if ( ! empty ( $conf -> agenda -> enabled )) {
2021-05-12 11:51:39 +02:00
print '<tr><td class="titlefield">' . $langs -> trans ( " ColorUser " ) . '</td>' ;
2017-10-07 13:09:31 +02:00
print '<td>' ;
print $formother -> showColor ( $object -> color , '' );
print '</td>' ;
print " </tr> \n " ;
}
2016-02-13 10:42:45 +01:00
2017-10-07 13:09:31 +02:00
// Categories
2021-02-26 13:18:40 +01:00
if ( ! empty ( $conf -> categorie -> enabled ) && ! empty ( $user -> rights -> categorie -> lire )) {
2021-05-12 11:51:39 +02:00
print '<tr><td class="titlefield">' . $langs -> trans ( " Categories " ) . '</td>' ;
2016-02-16 13:54:56 +01:00
print '<td colspan="3">' ;
2019-11-14 08:15:39 +01:00
print $form -> showCategories ( $object -> id , Categorie :: TYPE_USER , 1 );
2016-02-16 13:54:56 +01:00
print '</td></tr>' ;
2017-10-07 13:09:31 +02:00
}
2016-02-13 10:42:45 +01:00
2020-08-07 14:22:43 +02:00
// Default language
2021-02-26 13:18:40 +01:00
if ( ! empty ( $conf -> global -> MAIN_MULTILANGS )) {
2021-05-27 14:25:00 +02:00
$langs -> load ( " languages " );
2020-08-07 14:22:43 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php' ;
2021-05-27 14:25:00 +02:00
print '<tr><td class="titlefield">' ;
print $form -> textwithpicto ( $langs -> trans ( " DefaultLang " ), $langs -> trans ( " WarningNotLangOfInterface " , $langs -> transnoentitiesnoconv ( " UserGUISetup " )));
print '</td><td>' ;
2020-08-07 14:22:43 +02:00
//$s=picto_from_langcode($object->default_lang);
//print ($s?$s.' ':'');
$labellang = ( $object -> lang ? $langs -> trans ( 'Language_' . $object -> lang ) : '' );
2021-05-27 14:25:00 +02:00
print $labellang ;
2020-08-07 14:22:43 +02:00
print '</td></tr>' ;
}
2021-02-26 13:18:40 +01:00
if ( isset ( $conf -> file -> main_authentication ) && preg_match ( '/openid/' , $conf -> file -> main_authentication ) && ! empty ( $conf -> global -> MAIN_OPENIDURL_PERUSER )) {
2017-10-07 13:09:31 +02:00
print '<tr><td>' . $langs -> trans ( " OpenIDURL " ) . '</td>' ;
print '<td>' . $object -> openid . '</td>' ;
print " </tr> \n " ;
}
2017-06-06 07:57:03 +02:00
2020-09-07 10:18:17 +02:00
// Multicompany
2021-02-26 13:18:40 +01:00
if ( ! empty ( $conf -> multicompany -> enabled ) && is_object ( $mc )) {
2018-07-05 22:15:55 +02:00
// This is now done with hook formObjectOptions. Keep this code for backward compatibility with old multicompany module
2021-02-26 13:18:40 +01:00
if ( ! method_exists ( $mc , 'formObjectOptions' )) {
if ( ! empty ( $conf -> multicompany -> enabled ) && empty ( $conf -> global -> MULTICOMPANY_TRANSVERSE_MODE ) && $conf -> entity == 1 && $user -> admin && ! $user -> entity ) {
print '<tr><td>' . $langs -> trans ( " Entity " ) . '</td><td>' ;
if ( empty ( $object -> entity )) {
print $langs -> trans ( " AllEntities " );
} else {
$mc -> getInfo ( $object -> entity );
print $mc -> label ;
}
print " </td></tr> \n " ;
2020-09-07 10:18:17 +02:00
}
}
2018-07-05 22:15:55 +02:00
}
2017-08-25 13:25:34 +02:00
2017-10-07 13:09:31 +02:00
// Other attributes
2019-11-08 10:53:31 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php' ;
2017-06-06 07:57:03 +02:00
2017-10-07 13:09:31 +02:00
// Company / Contact
2021-02-26 13:18:40 +01:00
if ( ! empty ( $conf -> societe -> enabled )) {
2017-10-07 13:09:31 +02:00
print '<tr><td>' . $langs -> trans ( " LinkToCompanyContact " ) . '</td>' ;
print '<td>' ;
2020-10-15 19:36:08 +02:00
$s = '' ;
2021-02-26 13:18:40 +01:00
if ( isset ( $object -> socid ) && $object -> socid > 0 ) {
2017-10-07 13:09:31 +02:00
$societe = new Societe ( $db );
$societe -> fetch ( $object -> socid );
2020-10-31 14:32:18 +01:00
if ( $societe -> id > 0 ) {
2020-10-15 19:36:08 +02:00
$s .= $societe -> getNomUrl ( 1 , '' );
}
2020-05-21 15:05:19 +02:00
} else {
2020-11-22 01:16:32 +01:00
$s .= '<span class="opacitymedium hideonsmartphone">' . $langs -> trans ( " ThisUserIsNot " ) . '</span>' ;
2017-10-07 13:09:31 +02:00
}
2021-02-26 13:18:40 +01:00
if ( ! empty ( $object -> contact_id )) {
2017-10-07 13:09:31 +02:00
$contact = new Contact ( $db );
2020-06-25 12:17:47 +02:00
$contact -> fetch ( $object -> contact_id );
2020-10-15 19:36:08 +02:00
if ( $contact -> id > 0 ) {
2021-02-26 13:18:40 +01:00
if ( $object -> socid > 0 && $s ) {
$s .= ' / ' ;
} else {
$s .= '<br>' ;
}
2020-10-15 19:36:08 +02:00
$s .= $contact -> getNomUrl ( 1 , '' );
}
2017-10-07 13:09:31 +02:00
}
2020-10-15 19:36:08 +02:00
print $s ;
2017-10-07 13:09:31 +02:00
print '</td>' ;
print '</tr>' . " \n " ;
}
2011-06-29 12:23:32 +02:00
2017-10-07 13:09:31 +02:00
// Module Adherent
2021-02-26 13:18:40 +01:00
if ( ! empty ( $conf -> adherent -> enabled )) {
2017-10-07 13:09:31 +02:00
$langs -> load ( " members " );
print '<tr><td>' . $langs -> trans ( " LinkedToDolibarrMember " ) . '</td>' ;
print '<td>' ;
2021-02-26 13:18:40 +01:00
if ( $object -> fk_member ) {
2019-11-08 10:53:31 +01:00
$adh = new Adherent ( $db );
2017-10-07 13:09:31 +02:00
$adh -> fetch ( $object -> fk_member );
2019-11-08 10:53:31 +01:00
$adh -> ref = $adh -> getFullname ( $langs ); // Force to show login instead of id
2020-11-13 21:57:46 +01:00
print $adh -> getNomUrl ( - 1 );
2020-05-21 15:05:19 +02:00
} else {
2020-11-22 01:16:32 +01:00
print '<span class="opacitymedium hideonsmartphone">' . $langs -> trans ( " UserNotLinkedToMember " ) . '</span>' ;
2017-10-07 13:09:31 +02:00
}
print '</td>' ;
print '</tr>' . " \n " ;
}
2011-06-29 12:23:32 +02:00
2017-10-07 13:09:31 +02:00
// Signature
2021-04-25 15:27:10 +02:00
print '<tr><td class="tdtop">' . $langs -> trans ( 'Signature' ) . '</td><td class="wordbreak">' ;
2017-10-07 13:09:31 +02:00
print dol_htmlentitiesbr ( $object -> signature );
print " </td></tr> \n " ;
2017-05-19 12:58:38 +02:00
2021-04-25 15:09:56 +02:00
// VCard
2020-06-05 17:57:13 +02:00
print '<tr><td class="tdtop">' . $langs -> trans ( " VCard " ) . '</td>' ;
print '<td>' ;
print '<a href="' . DOL_URL_ROOT . '/user/vcard.php?id=' . $object -> id . '">' ;
print img_picto ( $langs -> trans ( " Download " ), 'vcard.png' , 'class="paddingrightonly"' );
print $langs -> trans ( " Download " );
print '</a>' ;
print " </td></tr> \n " ;
2017-10-07 13:09:31 +02:00
print " </table> \n " ;
2021-04-25 15:09:56 +02:00
2021-05-12 11:51:39 +02:00
// Credentials
2021-04-25 15:09:56 +02:00
print '<div class="div-table-responsive-no-min">' ;
2021-05-12 11:51:39 +02:00
print '<table class="border tableforfield margintable centpercent">' ;
2021-04-25 15:09:56 +02:00
print '<tr class="liste_titre"><td class="liste_titre">' ;
2021-05-12 11:51:39 +02:00
print img_picto ( '' , 'security' , 'class="paddingleft pictofixedwidth"' ) . $langs -> trans ( " Credentials " );
2021-04-25 15:09:56 +02:00
print '</td>' ;
2021-05-12 11:51:39 +02:00
print '<td class="liste_titre"></td>' ;
2021-04-25 15:09:56 +02:00
print '</tr>' ;
// Date login validity
print '<tr><td>' . $langs -> trans ( " RangeOfLoginValidity " ) . '</td>' ;
print '<td>' ;
if ( $object -> datestartvalidity ) {
print '<span class="opacitymedium">' . $langs -> trans ( " FromDate " ) . '</span> ' ;
print dol_print_date ( $object -> datestartvalidity , 'day' );
}
if ( $object -> dateendvalidity ) {
print '<span class="opacitymedium"> - ' . $langs -> trans ( " To " ) . '</span> ' ;
print dol_print_date ( $object -> dateendvalidity , 'day' );
}
print '</td>' ;
print " </tr> \n " ;
// Password
print '<tr><td class="titlefield">' . $langs -> trans ( " Password " ) . '</td>' ;
print '<td class="wordbreak">' ;
$valuetoshow = '' ;
if ( preg_match ( '/ldap/' , $dolibarr_main_authentication )) {
if ( ! empty ( $object -> ldap_sid )) {
if ( $passDoNotExpire ) {
$valuetoshow .= ( $valuetoshow ? ( ' ' . $langs -> trans ( " or " ) . ' ' ) : '' ) . $langs -> trans ( " LdapUacf_ " . $statutUACF );
} elseif ( $userChangePassNextLogon ) {
$valuetoshow .= ( $valuetoshow ? ( ' ' . $langs -> trans ( " or " ) . ' ' ) : '' ) . '<span class="warning">' . $langs -> trans ( " UserMustChangePassNextLogon " , $ldap -> domainFQDN ) . '</span>' ;
} elseif ( $userDisabled ) {
$valuetoshow .= ( $valuetoshow ? ( ' ' . $langs -> trans ( " or " ) . ' ' ) : '' ) . '<span class="warning">' . $langs -> trans ( " LdapUacf_ " . $statutUACF , $ldap -> domainFQDN ) . '</span>' ;
} else {
$valuetoshow .= ( $valuetoshow ? ( ' ' . $langs -> trans ( " or " ) . ' ' ) : '' ) . $langs -> trans ( " PasswordOfUserInLDAP " );
}
} else {
$valuetoshow .= ( $valuetoshow ? ( ' ' . $langs -> trans ( " or " ) . ' ' ) : '' ) . $langs -> trans ( " PasswordOfUserInLDAP " );
}
}
if ( preg_match ( '/http/' , $dolibarr_main_authentication )) {
$valuetoshow .= ( $valuetoshow ? ( ' ' . $langs -> trans ( " or " ) . ' ' ) : '' ) . $langs -> trans ( " HTTPBasicPassword " );
}
if ( preg_match ( '/dolibarr/' , $dolibarr_main_authentication )) {
if ( $object -> pass ) {
$valuetoshow .= ( $valuetoshow ? ( ' ' . $langs -> trans ( " or " ) . ' ' ) : '' );
$valuetoshow .= '<span class="opacitymedium">' . $langs -> trans ( " Hidden " ) . '</span>' ;
} else {
if ( $user -> admin && $user -> id == $object -> id ) {
$valuetoshow .= ( $valuetoshow ? ( ' ' . $langs -> trans ( " or " ) . ' ' ) : '' );
//$valuetoshow .= '<span class="opacitymedium">'.$langs->trans("Crypted").' - </span>';
$valuetoshow .= '<span class="opacitymedium">' . $langs -> trans ( " Hidden " ) . '</span>' ;
// TODO Add a feature to reveal the hash
$valuetoshow .= '<!-- Crypted into ' . $object -> pass_indatabase_crypted . ' -->' ;
} else {
$valuetoshow .= ( $valuetoshow ? ( ' ' . $langs -> trans ( " or " ) . ' ' ) : '' ) . '<span class="opacitymedium">' . $langs -> trans ( " Hidden " ) . '</span>' ;
}
}
}
// Other form for user password
$parameters = array ( 'valuetoshow' => $valuetoshow );
$reshook = $hookmanager -> executeHooks ( 'printUserPasswordField' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
if ( $reshook > 0 ) {
$valuetoshow = $hookmanager -> resPrint ; // to replace
} else {
$valuetoshow .= $hookmanager -> resPrint ; // to add
}
print $valuetoshow ;
print " </td> " ;
print '</tr>' . " \n " ;
// API key
2021-09-12 13:47:56 +02:00
if ( ! empty ( $conf -> api -> enabled ) && ( $user -> id == $id || $user -> admin || $user -> rights -> api -> apikey -> generate )) {
2021-04-25 15:09:56 +02:00
print '<tr><td>' . $langs -> trans ( " ApiKey " ) . '</td>' ;
print '<td>' ;
if ( ! empty ( $object -> api_key )) {
2021-05-12 11:51:39 +02:00
print '<span class="opacitymedium">' ;
2021-06-15 14:26:59 +02:00
print showValueWithClipboardCPButton ( $object -> api_key , 1 , $langs -> trans ( " Hidden " )); // TODO Add an option to also reveal the hash, not only copy paste
2021-05-12 11:51:39 +02:00
print '</span>' ;
2021-04-25 15:09:56 +02:00
}
print '</td></tr>' ;
}
2021-05-12 11:51:39 +02:00
print '<tr><td class="titlefield">' . $langs -> trans ( " LastConnexion " ) . '</td>' ;
print '<td>' ;
if ( $object -> datepreviouslogin ) {
print dol_print_date ( $object -> datepreviouslogin , " dayhour " ) . ' <span class="opacitymedium">(' . $langs -> trans ( " Previous " ) . ')</span>, ' ;
}
2021-05-31 12:02:03 +02:00
if ( $object -> datelastlogin ) {
2021-07-20 23:54:22 +02:00
print dol_print_date ( $object -> datelastlogin , " dayhour " ) . ' <span class="opacitymedium">(' . $langs -> trans ( " Currently " ) . ')</span>' ;
2021-05-31 12:02:03 +02:00
}
2021-05-12 11:51:39 +02:00
print '</td>' ;
print " </tr> \n " ;
2021-04-25 15:09:56 +02:00
print '</table></div>' ;
2015-10-11 15:21:21 +02:00
print '</div>' ;
2015-10-15 16:11:03 +02:00
2021-10-23 17:18:35 +02:00
print '</div>' ;
2017-10-07 13:09:31 +02:00
print '<div style="clear:both"></div>' ;
2015-10-15 16:11:03 +02:00
2011-06-29 12:23:32 +02:00
2020-10-27 18:19:31 +01:00
print dol_get_fiche_end ();
2011-06-29 12:23:32 +02:00
2017-10-07 13:09:31 +02:00
/*
2021-02-26 13:18:40 +01:00
* Buttons actions
*/
2011-06-29 12:23:32 +02:00
2017-10-07 13:09:31 +02:00
print '<div class="tabsAction">' ;
2011-06-29 12:23:32 +02:00
2019-11-08 10:53:31 +01:00
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'addMoreActionsButtons' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
2021-02-26 13:18:40 +01:00
if ( empty ( $reshook )) {
2020-04-10 01:37:04 +02:00
if ( empty ( $user -> socid )) {
2021-02-26 13:18:40 +01:00
if ( ! empty ( $object -> email )) {
2020-04-10 01:37:04 +02:00
$langs -> load ( " mails " );
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER [ 'PHP_SELF' ] . '?id=' . $object -> id . '&action=presend&mode=init#formmailbeforetitle">' . $langs -> trans ( 'SendMail' ) . '</a></div>' ;
2020-05-21 15:05:19 +02:00
} else {
2020-04-10 01:37:04 +02:00
$langs -> load ( " mails " );
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="' . dol_escape_htmltag ( $langs -> trans ( " NoEMail " )) . '">' . $langs -> trans ( 'SendMail' ) . '</a></div>' ;
}
2017-10-07 13:09:31 +02:00
}
2011-06-29 12:23:32 +02:00
2021-02-26 13:18:40 +01:00
if ( $caneditfield && ( empty ( $conf -> multicompany -> enabled ) || ! $user -> entity || ( $object -> entity == $conf -> entity ) || ( $conf -> global -> MULTICOMPANY_TRANSVERSE_MODE && $conf -> entity == 1 ))) {
2020-12-04 23:50:55 +01:00
if ( ! empty ( $conf -> global -> MAIN_ONLY_LOGIN_ALLOWED )) {
2018-11-13 21:40:17 +01:00
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="' . dol_escape_htmltag ( $langs -> trans ( " DisabledInMonoUserMode " )) . '">' . $langs -> trans ( " Modify " ) . '</a></div>' ;
2020-05-21 15:05:19 +02:00
} else {
2021-09-27 12:24:01 +02:00
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER [ 'PHP_SELF' ] . '?id=' . $object -> id . '&action=edit&token=' . newToken () . '">' . $langs -> trans ( " Modify " ) . '</a></div>' ;
2018-06-15 16:05:50 +02:00
}
2020-05-21 15:05:19 +02:00
} elseif ( $caneditpassword && ! $object -> ldap_sid &&
2021-02-26 13:18:40 +01:00
( empty ( $conf -> multicompany -> enabled ) || ! $user -> entity || ( $object -> entity == $conf -> entity ) || ( $conf -> global -> MULTICOMPANY_TRANSVERSE_MODE && $conf -> entity == 1 ))) {
2021-09-27 12:24:01 +02:00
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER [ 'PHP_SELF' ] . '?id=' . $object -> id . '&action=edit&token=' . newToken () . '">' . $langs -> trans ( " EditPassword " ) . '</a></div>' ;
2012-03-20 17:03:10 +01:00
}
2011-06-29 12:23:32 +02:00
2018-06-15 16:05:50 +02:00
// Si on a un gestionnaire de generation de mot de passe actif
2021-02-26 13:18:40 +01:00
if ( $conf -> global -> USER_PASSWORD_GENERATED != 'none' ) {
if ( $object -> statut == 0 ) {
2018-11-13 21:40:17 +01:00
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="' . dol_escape_htmltag ( $langs -> trans ( " UserDisabled " )) . '">' . $langs -> trans ( " ReinitPassword " ) . '</a></div>' ;
2021-12-19 17:12:01 +01:00
} elseif ( $caneditpassword && $object -> login && ! $object -> ldap_sid &&
2021-02-26 13:18:40 +01:00
(( empty ( $conf -> multicompany -> enabled ) && $object -> entity == $user -> entity ) || ! $user -> entity || ( $object -> entity == $conf -> entity ) || ( $conf -> global -> MULTICOMPANY_TRANSVERSE_MODE && $conf -> entity == 1 ))) {
2018-06-15 16:05:50 +02:00
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER [ 'PHP_SELF' ] . '?id=' . $object -> id . '&action=password">' . $langs -> trans ( " ReinitPassword " ) . '</a></div>' ;
}
2021-02-26 13:18:40 +01:00
if ( $object -> statut == 0 ) {
2018-11-13 21:40:17 +01:00
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="' . dol_escape_htmltag ( $langs -> trans ( " UserDisabled " )) . '">' . $langs -> trans ( " SendNewPassword " ) . '</a></div>' ;
2021-12-19 17:12:01 +01:00
} elseif ( $caneditpassword && $object -> login && ! $object -> ldap_sid &&
2021-02-26 13:18:40 +01:00
(( empty ( $conf -> multicompany -> enabled ) && $object -> entity == $user -> entity ) || ! $user -> entity || ( $object -> entity == $conf -> entity ) || ( $conf -> global -> MULTICOMPANY_TRANSVERSE_MODE && $conf -> entity == 1 ))) {
if ( $object -> email ) {
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER [ 'PHP_SELF' ] . '?id=' . $object -> id . '&action=passwordsend">' . $langs -> trans ( " SendNewPassword " ) . '</a></div>' ;
} else {
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="' . dol_escape_htmltag ( $langs -> trans ( " NoEMail " )) . '">' . $langs -> trans ( " SendNewPassword " ) . '</a></div>' ;
}
2018-06-15 16:05:50 +02:00
}
2012-03-20 17:03:10 +01:00
}
2018-06-15 16:05:50 +02:00
2019-02-27 13:48:13 +01:00
// Enable user
2018-06-15 16:05:50 +02:00
if ( $user -> id <> $id && $candisableuser && $object -> statut == 0 &&
2021-02-26 13:18:40 +01:00
(( empty ( $conf -> multicompany -> enabled ) && $object -> entity == $user -> entity ) || ! $user -> entity || ( $object -> entity == $conf -> entity ) || ( $conf -> global -> MULTICOMPANY_TRANSVERSE_MODE && $conf -> entity == 1 ))) {
2021-03-19 12:44:59 +01:00
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER [ 'PHP_SELF' ] . '?id=' . $object -> id . '&action=enable&token=' . newToken () . '">' . $langs -> trans ( " Reactivate " ) . '</a></div>' ;
2017-10-07 13:09:31 +02:00
}
2019-02-27 13:48:13 +01:00
// Disable user
2018-06-15 16:05:50 +02:00
if ( $user -> id <> $id && $candisableuser && $object -> statut == 1 &&
2021-02-26 13:18:40 +01:00
(( empty ( $conf -> multicompany -> enabled ) && $object -> entity == $user -> entity ) || ! $user -> entity || ( $object -> entity == $conf -> entity ) || ( $conf -> global -> MULTICOMPANY_TRANSVERSE_MODE && $conf -> entity == 1 ))) {
2021-03-19 12:44:59 +01:00
print '<div class="inline-block divButAction"><a class="butActionDelete" href="' . $_SERVER [ 'PHP_SELF' ] . '?action=disable&id=' . $object -> id . '&token=' . newToken () . '">' . $langs -> trans ( " DisableUser " ) . '</a></div>' ;
2020-05-21 15:05:19 +02:00
} else {
2021-02-26 13:18:40 +01:00
if ( $user -> id == $id ) {
2020-09-07 10:18:17 +02:00
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="' . $langs -> trans ( " CantDisableYourself " ) . '">' . $langs -> trans ( " DisableUser " ) . '</a></div>' ;
}
2019-02-27 13:48:13 +01:00
}
2018-06-15 16:05:50 +02:00
// Delete
if ( $user -> id <> $id && $candisableuser &&
2021-02-26 13:18:40 +01:00
(( empty ( $conf -> multicompany -> enabled ) && $object -> entity == $user -> entity ) || ! $user -> entity || ( $object -> entity == $conf -> entity ) || ( $conf -> global -> MULTICOMPANY_TRANSVERSE_MODE && $conf -> entity == 1 ))) {
if ( $user -> admin || ! $object -> admin ) { // If user edited is admin, delete is possible on for an admin
2021-03-19 12:44:59 +01:00
print '<div class="inline-block divButAction"><a class="butActionDelete" href="' . $_SERVER [ 'PHP_SELF' ] . '?action=delete&token=' . newToken () . '&id=' . $object -> id . '">' . $langs -> trans ( " DeleteUser " ) . '</a></div>' ;
2020-05-21 15:05:19 +02:00
} else {
2018-11-13 21:40:17 +01:00
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="' . dol_escape_htmltag ( $langs -> trans ( " MustBeAdminToDeleteOtherAdmin " )) . '">' . $langs -> trans ( " DeleteUser " ) . '</a></div>' ;
2018-06-15 16:05:50 +02:00
}
2017-10-07 13:09:31 +02:00
}
}
2018-07-05 22:15:55 +02:00
2017-10-07 13:09:31 +02:00
print " </div> \n " ;
2011-06-29 12:23:32 +02:00
2017-10-07 13:09:31 +02:00
//Select mail models is same action as presend
2021-02-26 13:18:40 +01:00
if ( GETPOST ( 'modelselected' )) {
$action = 'presend' ;
}
2017-10-08 16:34:42 +02:00
// Presend form
2019-11-08 10:53:31 +01:00
$modelmail = 'user' ;
$defaulttopic = 'Information' ;
2017-10-08 16:34:42 +02:00
$diroutput = $conf -> user -> dir_output ;
2018-01-22 17:15:44 +01:00
$trackid = 'use' . $object -> id ;
2017-10-08 16:34:42 +02:00
include DOL_DOCUMENT_ROOT . '/core/tpl/card_presend.tpl.php' ;
2021-02-26 13:18:40 +01:00
if ( $action != 'presend' && $action != 'send' ) {
2017-10-07 13:09:31 +02:00
/*
2021-02-26 13:18:40 +01:00
* List of groups of user
*/
2017-06-06 07:57:03 +02:00
2021-02-26 13:18:40 +01:00
if ( $canreadgroup ) {
2020-04-19 14:19:34 +02:00
print '<!-- Group section -->' . " \n " ;
2019-01-27 11:55:16 +01:00
print load_fiche_titre ( $langs -> trans ( " ListOfGroupsForUser " ), '' , '' );
2017-10-07 13:09:31 +02:00
// On selectionne les groupes auquel fait parti le user
$exclude = array ();
2019-11-08 10:53:31 +01:00
$usergroup = new UserGroup ( $db );
2021-11-01 13:47:52 +01:00
$groupslist = $usergroup -> listGroupsForUser ( $object -> id , false );
2017-10-07 13:09:31 +02:00
2021-02-26 13:18:40 +01:00
if ( ! empty ( $groupslist )) {
foreach ( $groupslist as $groupforuser ) {
2019-11-08 10:53:31 +01:00
$exclude [] = $groupforuser -> id ;
2017-10-07 13:09:31 +02:00
}
}
2017-11-04 15:40:35 +01:00
// Other form for add user to group
2019-11-08 10:53:31 +01:00
$parameters = array ( 'caneditgroup' => $caneditgroup , 'groupslist' => $groupslist , 'exclude' => $exclude );
$reshook = $hookmanager -> executeHooks ( 'formAddUserToGroup' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
2017-11-04 15:40:35 +01:00
print $hookmanager -> resPrint ;
2021-02-26 13:18:40 +01:00
if ( empty ( $reshook )) {
if ( $caneditgroup ) {
2019-11-15 09:02:21 +01:00
print '<form action="' . $_SERVER [ 'PHP_SELF' ] . '?id=' . $id . '" method="POST">' . " \n " ;
2019-12-01 10:20:11 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '" />' ;
2019-11-15 09:02:21 +01:00
print '<input type="hidden" name="action" value="addgroup" />' ;
2021-11-25 10:28:37 +01:00
print '<input type="hidden" name="page_y" value="" />' ;
2019-11-15 09:02:21 +01:00
}
print '<table class="noborder centpercent">' . " \n " ;
2017-11-04 15:40:35 +01:00
print '<tr class="liste_titre"><th class="liste_titre">' . $langs -> trans ( " Groups " ) . '</th>' . " \n " ;
2019-02-16 10:29:15 +01:00
print '<th class="liste_titre right">' ;
2021-02-26 13:18:40 +01:00
if ( $caneditgroup ) {
2017-10-07 13:09:31 +02:00
print $form -> select_dolgroups ( '' , 'group' , 1 , $exclude , 0 , '' , '' , $object -> entity );
print ' ' ;
2017-11-04 15:40:35 +01:00
print '<input type="hidden" name="entity" value="' . $conf -> entity . '" />' ;
2021-11-25 10:28:37 +01:00
print '<input type="submit" class="button buttongen button-add reposition" value="' . $langs -> trans ( " Add " ) . '" />' ;
2017-11-04 15:40:35 +01:00
}
print '</th></tr>' . " \n " ;
2020-04-19 14:19:34 +02:00
// List of groups of user
2021-02-26 13:18:40 +01:00
if ( ! empty ( $groupslist )) {
foreach ( $groupslist as $group ) {
2017-11-04 15:40:35 +01:00
print '<tr class="oddeven">' ;
print '<td>' ;
2021-02-26 13:18:40 +01:00
if ( $caneditgroup ) {
2020-04-19 14:23:31 +02:00
print $group -> getNomUrl ( 1 );
2020-05-21 15:05:19 +02:00
} else {
2019-01-27 11:55:16 +01:00
print img_object ( $langs -> trans ( " ShowGroup " ), " group " ) . ' ' . $group -> name ;
2017-10-07 13:09:31 +02:00
}
2017-11-04 15:40:35 +01:00
print '</td>' ;
2019-02-16 10:29:15 +01:00
print '<td class="right">' ;
2021-02-26 13:18:40 +01:00
if ( $caneditgroup ) {
2021-11-25 10:28:37 +01:00
print '<a class="reposition" href="' . $_SERVER [ 'PHP_SELF' ] . '?id=' . $object -> id . '&action=removegroup&token=' . newToken () . '&group=' . (( int ) $group -> id ) . '">' ;
2018-08-19 02:43:45 +02:00
print img_picto ( $langs -> trans ( " RemoveFromGroup " ), 'unlink' );
2017-11-04 15:40:35 +01:00
print '</a>' ;
2020-05-21 15:05:19 +02:00
} else {
2017-11-04 15:40:35 +01:00
print " " ;
}
print " </td></tr> \n " ;
2017-10-07 13:09:31 +02:00
}
2020-05-21 15:05:19 +02:00
} else {
2018-02-25 12:41:17 +01:00
print '<tr class="oddeven"><td colspan="3" class="opacitymedium">' . $langs -> trans ( " None " ) . '</td></tr>' ;
2017-11-04 15:40:35 +01:00
}
2017-06-06 07:57:03 +02:00
2019-11-15 09:02:21 +01:00
print " </table> " ;
2017-10-07 13:09:31 +02:00
2021-02-26 13:18:40 +01:00
if ( $caneditgroup ) {
2019-11-15 09:02:21 +01:00
print '</form>' ;
}
print " <br> " ;
2017-10-07 13:09:31 +02:00
}
}
}
}
/*
2021-02-26 13:18:40 +01:00
* Card in edit mode
*/
if ( $action == 'edit' && ( $canedituser || $caneditfield || $caneditpassword || ( $user -> id == $object -> id ))) {
2017-10-07 13:09:31 +02:00
print '<form action="' . $_SERVER [ 'PHP_SELF' ] . '?id=' . $object -> id . '" method="POST" name="updateuser" enctype="multipart/form-data">' ;
2019-12-01 10:20:11 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2017-10-07 13:09:31 +02:00
print '<input type="hidden" name="action" value="update">' ;
print '<input type="hidden" name="entity" value="' . $object -> entity . '">' ;
2017-05-19 12:58:38 +02:00
2020-10-22 22:50:03 +02:00
print dol_get_fiche_head ( $head , 'user' , $title , 0 , 'user' );
2017-05-19 12:58:38 +02:00
2019-02-16 10:29:15 +01:00
print '<table class="border centpercent">' ;
2017-05-19 12:58:38 +02:00
2017-10-07 13:09:31 +02:00
// Ref/ID
2021-02-26 13:18:40 +01:00
if ( ! empty ( $conf -> global -> MAIN_SHOW_TECHNICAL_ID )) {
2021-03-25 08:37:59 +01:00
print '<tr><td class="titlefieldcreate">' . $langs -> trans ( " Ref " ) . '</td>' ;
2017-10-07 13:09:31 +02:00
print '<td>' ;
print $object -> id ;
print '</td>' ;
print '</tr>' ;
2017-05-19 12:58:38 +02:00
}
2020-12-05 11:30:18 +01:00
// Civility
2021-03-25 08:37:59 +01:00
print '<tr><td class="titlefieldcreate"><label for="civility_code">' . $langs -> trans ( " UserTitle " ) . '</label></td><td colspan="3">' ;
2021-10-22 02:53:37 +02:00
if ( $caneditfield && ! $object -> ldap_sid ) {
print $formcompany -> select_civility ( GETPOSTISSET ( " civility_code " ) ? GETPOST ( " civility_code " , 'aZ09' ) : $object -> civility_code , 'civility_code' );
} elseif ( $object -> civility_code ) {
print $langs -> trans ( " Civility " . $object -> civility_code );
}
2020-12-05 11:30:18 +01:00
print '</td></tr>' ;
2017-10-07 13:09:31 +02:00
// Lastname
print " <tr> " ;
2021-03-25 08:37:59 +01:00
print '<td class="titlefieldcreate fieldrequired">' . $langs -> trans ( " Lastname " ) . '</td>' ;
2017-10-07 13:09:31 +02:00
print '<td>' ;
2021-02-26 13:18:40 +01:00
if ( $caneditfield && ! $object -> ldap_sid ) {
2017-10-07 13:09:31 +02:00
print '<input class="minwidth100" type="text" class="flat" name="lastname" value="' . $object -> lastname . '">' ;
2020-05-21 15:05:19 +02:00
} else {
2017-10-07 13:09:31 +02:00
print '<input type="hidden" name="lastname" value="' . $object -> lastname . '">' ;
print $object -> lastname ;
}
print '</td>' ;
print '</tr>' ;
2017-05-19 12:58:38 +02:00
2017-10-07 13:09:31 +02:00
// Firstname
print " <tr> " . '<td>' . $langs -> trans ( " Firstname " ) . '</td>' ;
print '<td>' ;
2021-02-26 13:18:40 +01:00
if ( $caneditfield && ! $object -> ldap_sid ) {
2017-10-07 13:09:31 +02:00
print '<input class="minwidth100" type="text" class="flat" name="firstname" value="' . $object -> firstname . '">' ;
2020-05-21 15:05:19 +02:00
} else {
2017-10-07 13:09:31 +02:00
print '<input type="hidden" name="firstname" value="' . $object -> firstname . '">' ;
print $object -> firstname ;
}
print '</td></tr>' ;
// Login
print " <tr> " . '<td><span class="fieldrequired">' . $langs -> trans ( " Login " ) . '</span></td>' ;
print '<td>' ;
2021-02-26 13:18:40 +01:00
if ( $user -> admin && ! $object -> ldap_sid ) {
2020-02-08 14:52:02 +01:00
print '<input maxlength="50" type="text" class="flat" name="login" value="' . $object -> login . '">' ;
2020-05-21 15:05:19 +02:00
} else {
2017-10-07 13:09:31 +02:00
print '<input type="hidden" name="login" value="' . $object -> login . '">' ;
print $object -> login ;
}
print '</td>' ;
print '</tr>' ;
2017-05-19 12:58:38 +02:00
2017-10-07 13:09:31 +02:00
// Administrator
print '<tr><td>' . $langs -> trans ( " Administrator " ) . '</td>' ;
2021-02-26 13:18:40 +01:00
if ( $object -> socid > 0 ) {
2017-10-07 13:09:31 +02:00
$langs -> load ( " admin " );
print '<td>' ;
print '<input type="hidden" name="admin" value="' . $object -> admin . '">' . yn ( $object -> admin );
print ' (' . $langs -> trans ( " ExternalUser " ) . ')' ;
print '</td></tr>' ;
2020-05-21 15:05:19 +02:00
} else {
2017-10-07 13:09:31 +02:00
print '<td>' ;
2019-01-27 11:55:16 +01:00
$nbAdmin = $user -> getNbOfUsers ( 'active' , '' , 1 );
$nbSuperAdmin = $user -> getNbOfUsers ( 'active' , 'superadmin' , 1 );
2017-10-07 13:09:31 +02:00
//var_dump($nbAdmin);
//var_dump($nbSuperAdmin);
if ( $user -> admin // Need to be admin to allow downgrade of an admin
&& ( $user -> id != $object -> id ) // Don't downgrade ourself
&& (
( empty ( $conf -> multicompany -> enabled ) && $nbAdmin >= 1 )
2019-11-08 10:53:31 +01:00
|| ( ! empty ( $conf -> multicompany -> enabled ) && (( $object -> entity > 0 || ( $user -> entity == 0 && $object -> entity == 0 )) || $nbSuperAdmin > 1 )) // Don't downgrade a superadmin if alone
2017-10-07 13:09:31 +02:00
)
2021-02-26 13:18:40 +01:00
) {
2019-01-27 11:55:16 +01:00
print $form -> selectyesno ( 'admin' , $object -> admin , 1 );
2017-10-07 13:09:31 +02:00
2021-02-26 13:18:40 +01:00
if ( ! empty ( $conf -> multicompany -> enabled ) && ! $user -> entity ) {
if ( $conf -> use_javascript_ajax ) {
2017-10-07 13:09:31 +02:00
print ' < script type = " text/javascript " >
2017-05-19 12:58:38 +02:00
$ ( function () {
var admin = $ ( " select[name=admin] " ) . val ();
if ( admin == 0 ) {
$ ( " input[name=superadmin] " )
. prop ( " disabled " , true )
. prop ( " checked " , false );
}
if ( $ ( " input[name=superadmin] " ) . is ( " :checked " )) {
$ ( " select[name=entity] " )
. prop ( " disabled " , true );
}
$ ( " select[name=admin] " ) . change ( function () {
if ( $ ( this ) . val () == 0 ) {
$ ( " input[name=superadmin] " )
. prop ( " disabled " , true )
. prop ( " checked " , false );
$ ( " select[name=entity] " )
. prop ( " disabled " , false );
} else {
$ ( " input[name=superadmin] " )
. prop ( " disabled " , false );
}
});
$ ( " input[name=superadmin] " ) . change ( function () {
if ( $ ( this ) . is ( " :checked " )) {
$ ( " select[name=entity] " )
. prop ( " disabled " , true );
} else {
$ ( " select[name=entity] " )
. prop ( " disabled " , false );
}
});
});
</ script > ' ;
2017-10-07 13:09:31 +02:00
}
2019-11-08 10:53:31 +01:00
$checked = (( $object -> admin && ! $object -> entity ) ? ' checked' : '' );
2021-03-17 22:01:25 +01:00
print '<input type="checkbox" name="superadmin" id="superadmin" value="1"' . $checked . ' /> <label for="superadmin">' . $langs -> trans ( " SuperAdministrator " ) . '</span>' ;
2017-10-07 13:09:31 +02:00
}
2020-05-21 15:05:19 +02:00
} else {
2017-10-07 13:09:31 +02:00
$yn = yn ( $object -> admin );
print '<input type="hidden" name="admin" value="' . $object -> admin . '">' ;
print '<input type="hidden" name="superadmin" value="' . ( empty ( $object -> entity ) ? 1 : 0 ) . '">' ;
2021-02-26 13:18:40 +01:00
if ( ! empty ( $conf -> multicompany -> enabled ) && empty ( $object -> entity )) {
print $form -> textwithpicto ( $yn , $langs -> trans ( " DontDowngradeSuperAdmin " ), 1 , 'warning' );
} else {
print $yn ;
}
2017-10-07 13:09:31 +02:00
}
print '</td></tr>' ;
}
2017-05-19 12:58:38 +02:00
2021-02-26 13:18:40 +01:00
// Gender
print '<tr><td>' . $langs -> trans ( " Gender " ) . '</td>' ;
print '<td>' ;
$arraygender = array ( 'man' => $langs -> trans ( " Genderman " ), 'woman' => $langs -> trans ( " Genderwoman " ), 'other' => $langs -> trans ( " Genderother " ));
if ( $caneditfield ) {
print $form -> selectarray ( 'gender' , $arraygender , GETPOSTISSET ( 'gender' ) ? GETPOST ( 'gender' ) : $object -> gender , 1 );
} else {
print $arraygender [ $object -> gender ];
}
print '</td></tr>' ;
2017-12-19 16:16:31 +01:00
2020-09-07 10:18:17 +02:00
// Employee
print '<tr>' ;
print '<td>' . $form -> editfieldkey ( 'Employee' , 'employee' , '' , $object , 0 ) . '</td><td>' ;
if ( $caneditfield ) {
2021-04-25 15:09:56 +02:00
print '<input type="checkbox" name="employee" value="1"' . ( $object -> employee ? ' checked="checked"' : '' ) . '>' ;
//print $form->selectyesno("employee", $object->employee, 1);
2018-11-15 22:01:36 +01:00
} else {
2021-04-25 15:09:56 +02:00
print '<input type="checkbox" name="employee" disabled value="1"' . ( $object -> employee ? ' checked="checked"' : '' ) . '>' ;
/* if ( $object -> employee ) {
2018-11-14 18:29:15 +01:00
print $langs -> trans ( " Yes " );
2018-11-15 22:01:36 +01:00
} else {
2018-11-14 18:29:15 +01:00
print $langs -> trans ( " No " );
2021-04-25 15:09:56 +02:00
} */
2018-11-14 18:29:15 +01:00
}
2020-09-07 10:18:17 +02:00
print '</td></tr>' ;
2017-12-19 16:16:31 +01:00
2020-09-07 10:18:17 +02:00
// Hierarchy
2021-02-26 13:18:40 +01:00
print '<tr><td class="titlefield">' . $langs -> trans ( " HierarchicalResponsible " ) . '</td>' ;
print '<td>' ;
if ( $caneditfield ) {
2021-06-15 15:19:46 +02:00
print img_picto ( '' , 'user' ) . $form -> select_dolusers ( $object -> fk_user , 'fk_user' , 1 , array ( $object -> id ), 0 , '' , 0 , $object -> entity , 0 , 0 , '' , 0 , '' , 'widthcentpercentminusx maxwidth300' );
2021-02-26 13:18:40 +01:00
} else {
print '<input type="hidden" name="fk_user" value="' . $object -> fk_user . '">' ;
$huser = new User ( $db );
$huser -> fetch ( $object -> fk_user );
print $huser -> getNomUrl ( 1 );
}
print '</td>' ;
print " </tr> \n " ;
2017-12-19 16:16:31 +01:00
2019-10-02 08:43:40 +02:00
// Expense report validator
2020-06-03 23:30:06 +02:00
if ( ! empty ( $conf -> expensereport -> enabled )) {
print '<tr><td class="titlefield">' ;
$text = $langs -> trans ( " ForceUserExpenseValidator " );
print $form -> textwithpicto ( $text , $langs -> trans ( " ValidatorIsSupervisorByDefault " ), 1 , 'help' );
print '</td>' ;
print '<td>' ;
2021-02-26 13:18:40 +01:00
if ( $caneditfield ) {
2021-06-15 15:19:46 +02:00
print img_picto ( '' , 'user' ) . $form -> select_dolusers ( $object -> fk_user_expense_validator , 'fk_user_expense_validator' , 1 , array ( $object -> id ), 0 , '' , 0 , $object -> entity , 0 , 0 , '' , 0 , '' , 'widthcentpercentminusx maxwidth300' );
2020-06-03 23:30:06 +02:00
} else {
2020-06-06 23:04:55 +02:00
print '<input type="hidden" name="fk_user_expense_validator" value="' . $object -> fk_user_expense_validator . '">' ;
2020-06-03 23:30:06 +02:00
$evuser = new User ( $db );
$evuser -> fetch ( $object -> fk_user_expense_validator );
print $evuser -> getNomUrl ( 1 );
}
print '</td>' ;
print " </tr> \n " ;
2019-10-02 08:43:40 +02:00
}
// Holiday request validator
2020-06-03 23:30:06 +02:00
if ( ! empty ( $conf -> holiday -> enabled )) {
print '<tr><td class="titlefield">' ;
$text = $langs -> trans ( " ForceUserHolidayValidator " );
print $form -> textwithpicto ( $text , $langs -> trans ( " ValidatorIsSupervisorByDefault " ), 1 , 'help' );
print '</td>' ;
print '<td>' ;
2021-02-26 13:18:40 +01:00
if ( $caneditfield ) {
2021-06-15 15:19:46 +02:00
print img_picto ( '' , 'user' ) . $form -> select_dolusers ( $object -> fk_user_holiday_validator , 'fk_user_holiday_validator' , 1 , array ( $object -> id ), 0 , '' , 0 , $object -> entity , 0 , 0 , '' , 0 , '' , 'widthcentpercentminusx maxwidth300' );
2020-06-03 23:30:06 +02:00
} else {
2020-06-06 23:04:55 +02:00
print '<input type="hidden" name="fk_user_holiday_validator" value="' . $object -> fk_user_holiday_validator . '">' ;
2020-06-03 23:30:06 +02:00
$hvuser = new User ( $db );
$hvuser -> fetch ( $object -> fk_user_holiday_validator );
print $hvuser -> getNomUrl ( 1 );
}
print '</td>' ;
print " </tr> \n " ;
2019-10-02 08:43:40 +02:00
}
2020-12-07 14:25:49 +01:00
// External user ?
print '<tr><td>' . $langs -> trans ( " ExternalUser " ) . ' ?</td>' ;
print '<td>' ;
2021-02-26 13:18:40 +01:00
if ( $user -> id == $object -> id || ! $user -> admin ) {
2020-12-07 14:25:49 +01:00
// Read mode
$type = $langs -> trans ( " Internal " );
2021-02-26 13:18:40 +01:00
if ( $object -> socid ) {
$type = $langs -> trans ( " External " );
}
2020-12-07 14:25:49 +01:00
print $form -> textwithpicto ( $type , $langs -> trans ( " InternalExternalDesc " ));
2021-02-26 13:18:40 +01:00
if ( $object -> ldap_sid ) {
print ' (' . $langs -> trans ( " DomainUser " ) . ')' ;
}
2020-12-07 14:25:49 +01:00
} else {
// Select mode
$type = 0 ;
2021-02-26 13:18:40 +01:00
if ( $object -> contact_id ) {
$type = $object -> contact_id ;
}
2020-12-07 14:25:49 +01:00
if ( $object -> socid > 0 && ! ( $object -> contact_id > 0 )) { // external user but no link to a contact
print img_picto ( '' , 'company' ) . $form -> select_company ( $object -> socid , 'socid' , '' , ' ' );
print img_picto ( '' , 'contact' ) . $form -> selectcontacts ( 0 , 0 , 'contactid' , 1 , '' , '' , 1 , '' , false , 1 );
2021-02-26 13:18:40 +01:00
if ( $object -> ldap_sid ) {
print ' (' . $langs -> trans ( " DomainUser " ) . ')' ;
}
2020-12-07 14:25:49 +01:00
} elseif ( $object -> socid > 0 && $object -> contact_id > 0 ) { // external user with a link to a contact
print img_picto ( '' , 'company' ) . $form -> select_company ( 0 , 'socid' , '' , ' ' ); // We keep thirdparty empty, contact is already set
print img_picto ( '' , 'contact' ) . $form -> selectcontacts ( 0 , $object -> contact_id , 'contactid' , 1 , '' , '' , 1 , '' , false , 1 );
2021-02-26 13:18:40 +01:00
if ( $object -> ldap_sid ) {
print ' (' . $langs -> trans ( " DomainUser " ) . ')' ;
}
2020-12-07 14:25:49 +01:00
} else { // $object->socid is not > 0 here
print img_picto ( '' , 'company' ) . $form -> select_company ( 0 , 'socid' , '' , ' ' ); // We keep thirdparty empty, contact is already set
print img_picto ( '' , 'contact' ) . $form -> selectcontacts ( 0 , 0 , 'contactid' , 1 , '' , '' , 1 , '' , false , 1 );
}
}
print '</td></tr>' ;
2017-12-19 16:16:31 +01:00
2021-04-25 15:09:56 +02:00
print '</table><hr><table class="border centpercent">' ;
// Date access validity
print '<tr><td>' . $langs -> trans ( " RangeOfLoginValidity " ) . '</td>' ;
print '<td>' ;
if ( $caneditfield ) {
print $form -> selectDate ( $datestartvalidity ? $datestartvalidity : $object -> datestartvalidity , 'datestartvalidity' , 0 , 0 , 1 , 'formdatestartvalidity' , 1 , 1 , 0 , '' , '' , '' , '' , 1 , '' , '' );
} else {
print dol_print_date ( $object -> datestartvalidity , 'day' );
}
/* if ( $datestartvalidity && $dateendvalidity ) {
print ' - ' ;
} */
print ' ' ;
if ( $caneditfield ) {
print $form -> selectDate ( $dateendvalidity ? $datendevalidity : $object -> dateendvalidity , 'dateendvalidity' , 0 , 0 , 1 , 'formdateendvalidity' , 1 , 0 , 0 , '' , '' , '' , '' , 1 , '' , '' );
} else {
print dol_print_date ( $object -> dateendvalidity , 'day' );
}
print '</td>' ;
print " </tr> \n " ;
// Pass
print '<tr><td class="titlefieldcreate">' . $langs -> trans ( " Password " ) . '</td>' ;
print '<td>' ;
$valuetoshow = '' ;
if ( preg_match ( '/ldap/' , $dolibarr_main_authentication )) {
$valuetoshow .= ( $valuetoshow ? ( ' ' . $langs -> trans ( " or " ) . ' ' ) : '' ) . $langs -> trans ( " PasswordOfUserInLDAP " );
}
if ( preg_match ( '/http/' , $dolibarr_main_authentication )) {
$valuetoshow .= ( $valuetoshow ? ( ' ' . $langs -> trans ( " or " ) . ' ' ) : '' ) . $form -> textwithpicto ( $text , $langs -> trans ( " DolibarrInHttpAuthenticationSoPasswordUseless " , $dolibarr_main_authentication ), 1 , 'warning' );
}
if ( preg_match ( '/dolibarr/' , $dolibarr_main_authentication )) {
if ( $caneditpassword ) {
2021-09-05 15:35:06 +02:00
$valuetoshow .= ( $valuetoshow ? ( ' ' . $langs -> trans ( " or " ) . ' ' ) : '' ) . '<input maxlength="128" type="password" class="flat" name="password" value="' . $object -> pass . '" autocomplete="new-password">' ;
2021-04-25 15:09:56 +02:00
} else {
$valuetoshow .= ( $valuetoshow ? ( ' ' . $langs -> trans ( " or " ) . ' ' ) : '' ) . preg_replace ( '/./i' , '*' , $object -> pass );
}
}
// Other form for user password
$parameters = array ( 'valuetoshow' => $valuetoshow , 'caneditpassword' => $caneditpassword );
$reshook = $hookmanager -> executeHooks ( 'printUserPasswordField' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
if ( $reshook > 0 ) {
$valuetoshow = $hookmanager -> resPrint ; // to replace
} else {
$valuetoshow .= $hookmanager -> resPrint ; // to add
}
print $valuetoshow ;
print " </td></tr> \n " ;
// API key
2021-09-12 13:47:56 +02:00
if ( ! empty ( $conf -> api -> enabled ) && ( $user -> id == $id || $user -> admin || $user -> rights -> api -> apikey -> generate )) {
2021-04-25 15:09:56 +02:00
print '<tr><td>' . $langs -> trans ( " ApiKey " ) . '</td>' ;
print '<td>' ;
print '<input class="minwidth300" maxsize="32" type="text" id="api_key" name="api_key" value="' . $object -> api_key . '" autocomplete="off">' ;
if ( ! empty ( $conf -> use_javascript_ajax )) {
print ' ' . img_picto ( $langs -> trans ( 'Generate' ), 'refresh' , 'id="generate_api_key" class="linkobject"' );
}
print '</td></tr>' ;
}
2021-10-28 14:28:04 +02:00
// OpenID url
if ( isset ( $conf -> file -> main_authentication ) && preg_match ( '/openid/' , $conf -> file -> main_authentication ) && ! empty ( $conf -> global -> MAIN_OPENIDURL_PERUSER )) {
print " <tr> " . '<td>' . $langs -> trans ( " OpenIDURL " ) . '</td>' ;
print '<td>' ;
if ( $caneditfield ) {
print '<input class="minwidth100" type="url" name="openid" class="flat" value="' . $object -> openid . '">' ;
} else {
print '<input type="hidden" name="openid" value="' . $object -> openid . '">' ;
print $object -> openid ;
}
print '</td></tr>' ;
}
2021-04-25 15:09:56 +02:00
2021-02-26 13:18:40 +01:00
print '</table><hr><table class="border centpercent">' ;
2017-12-19 16:16:31 +01:00
2017-05-19 12:58:38 +02:00
// Address
2021-04-18 20:53:09 +02:00
print '<tr><td class="tdtop titlefieldcreate">' . $form -> editfieldkey ( 'Address' , 'address' , '' , $object , 0 ) . '</td>' ;
2020-02-12 17:28:18 +01:00
print '<td>' ;
2021-02-26 13:18:40 +01:00
if ( $caneditfield ) {
print '<textarea name="address" id="address" class="quatrevingtpercent" rows="3" wrap="soft">' ;
}
2017-10-07 13:09:31 +02:00
print $object -> address ;
2021-02-26 13:18:40 +01:00
if ( $caneditfield ) {
print '</textarea>' ;
}
2020-02-12 17:28:18 +01:00
print '</td></tr>' ;
2017-05-19 12:58:38 +02:00
2017-10-07 13:09:31 +02:00
// Zip
2018-10-27 17:45:29 +02:00
print '<tr><td>' . $form -> editfieldkey ( 'Zip' , 'zipcode' , '' , $object , 0 ) . '</td><td>' ;
2020-02-12 17:28:18 +01:00
if ( $caneditfield ) {
print $formcompany -> select_ziptown ( $object -> zip , 'zipcode' , array ( 'town' , 'selectcountry_id' , 'state_id' ), 6 );
} else {
print $object -> zip ;
}
2017-10-07 13:09:31 +02:00
print '</td></tr>' ;
2017-05-19 12:58:38 +02:00
// Town
2018-10-27 17:45:29 +02:00
print '<tr><td>' . $form -> editfieldkey ( 'Town' , 'town' , '' , $object , 0 ) . '</td><td>' ;
2020-02-12 17:28:18 +01:00
if ( $caneditfield ) {
print $formcompany -> select_ziptown ( $object -> town , 'town' , array ( 'zipcode' , 'selectcountry_id' , 'state_id' ));
} else {
print $object -> town ;
}
2017-10-07 13:09:31 +02:00
print '</td></tr>' ;
2017-05-19 12:58:38 +02:00
2017-10-07 13:09:31 +02:00
// Country
2018-10-27 17:45:29 +02:00
print '<tr><td>' . $form -> editfieldkey ( 'Country' , 'selectcounty_id' , '' , $object , 0 ) . '</td><td>' ;
2020-02-12 17:28:18 +01:00
if ( $caneditfield ) {
print $form -> select_country (( GETPOST ( 'country_id' ) != '' ? GETPOST ( 'country_id' ) : $object -> country_id ), 'country_id' );
2021-02-26 13:18:40 +01:00
if ( $user -> admin ) {
print info_admin ( $langs -> trans ( " YouCanChangeValuesForThisListFromDictionarySetup " ), 1 );
}
2020-02-12 17:28:18 +01:00
} else {
$countrylabel = getCountry ( $object -> country_id , '0' );
print $countrylabel ;
}
2017-10-07 13:09:31 +02:00
print '</td></tr>' ;
2017-05-19 12:58:38 +02:00
2017-10-07 13:09:31 +02:00
// State
2021-02-26 13:18:40 +01:00
if ( empty ( $conf -> global -> USER_DISABLE_STATE )) {
2018-10-27 17:45:29 +02:00
print '<tr><td class="tdoverflow">' . $form -> editfieldkey ( 'State' , 'state_id' , '' , $object , 0 ) . '</td><td>' ;
2020-02-12 17:28:18 +01:00
if ( $caneditfield ) {
2021-07-04 19:23:04 +02:00
print img_picto ( '' , 'state' , 'class="pictofixedwidth"' );
2020-02-12 17:28:18 +01:00
print $formcompany -> select_state ( $object -> state_id , $object -> country_code , 'state_id' );
} else {
print $object -> state_label ;
}
2017-10-07 13:09:31 +02:00
print '</td></tr>' ;
}
2017-05-19 12:58:38 +02:00
2017-10-07 13:09:31 +02:00
// Tel pro
2020-11-24 16:54:13 +01:00
print " <tr> " . '<td>' . $langs -> trans ( " PhonePro " ) . '</td>' ;
2017-10-07 13:09:31 +02:00
print '<td>' ;
2021-06-15 15:19:46 +02:00
print img_picto ( '' , 'phoning' , 'class="pictofixedwidth"' );
2021-02-26 13:18:40 +01:00
if ( $caneditfield && empty ( $object -> ldap_sid )) {
2020-11-24 16:54:13 +01:00
print '<input type="text" name="office_phone" class="flat maxwidth200" value="' . $object -> office_phone . '">' ;
2020-05-21 15:05:19 +02:00
} else {
2017-10-07 13:09:31 +02:00
print '<input type="hidden" name="office_phone" value="' . $object -> office_phone . '">' ;
print $object -> office_phone ;
}
print '</td></tr>' ;
2017-05-19 12:58:38 +02:00
2017-10-07 13:09:31 +02:00
// Tel mobile
2020-11-24 16:54:13 +01:00
print " <tr> " . '<td>' . $langs -> trans ( " PhoneMobile " ) . '</td>' ;
2017-10-07 13:09:31 +02:00
print '<td>' ;
2021-06-15 15:19:46 +02:00
print img_picto ( '' , 'phoning_mobile' , 'class="pictofixedwidth"' );
2021-02-26 13:18:40 +01:00
if ( $caneditfield && empty ( $object -> ldap_sid )) {
2020-11-24 16:54:13 +01:00
print '<input type="text" name="user_mobile" class="flat maxwidth200" value="' . $object -> user_mobile . '">' ;
2020-05-21 15:05:19 +02:00
} else {
2017-10-07 13:09:31 +02:00
print '<input type="hidden" name="user_mobile" value="' . $object -> user_mobile . '">' ;
print $object -> user_mobile ;
}
print '</td></tr>' ;
2017-05-19 12:58:38 +02:00
2017-10-07 13:09:31 +02:00
// Fax
2020-11-24 16:54:13 +01:00
print " <tr> " . '<td>' . $langs -> trans ( " Fax " ) . '</td>' ;
2017-10-07 13:09:31 +02:00
print '<td>' ;
2021-06-15 15:19:46 +02:00
print img_picto ( '' , 'phoning_fax' , 'class="pictofixedwidth"' );
2021-02-26 13:18:40 +01:00
if ( $caneditfield && empty ( $object -> ldap_sid )) {
2020-11-24 16:54:13 +01:00
print '<input type="text" name="office_fax" class="flat maxwidth200" value="' . $object -> office_fax . '">' ;
2020-05-21 15:05:19 +02:00
} else {
2017-10-07 13:09:31 +02:00
print '<input type="hidden" name="office_fax" value="' . $object -> office_fax . '">' ;
print $object -> office_fax ;
}
print '</td></tr>' ;
2017-05-19 12:58:38 +02:00
2019-10-23 21:27:29 +02:00
// EMail
2020-11-24 16:54:13 +01:00
print " <tr> " . '<td' . ( ! empty ( $conf -> global -> USER_MAIL_REQUIRED ) ? ' class="fieldrequired"' : '' ) . '>' . $langs -> trans ( " EMail " ) . '</td>' ;
2019-10-23 21:27:29 +02:00
print '<td>' ;
2021-06-15 15:19:46 +02:00
print img_picto ( '' , 'object_email' , 'class="pictofixedwidth"' );
2021-02-26 13:18:40 +01:00
if ( $caneditfield && empty ( $object -> ldap_sid )) {
2020-11-24 16:54:13 +01:00
print '<input class="minwidth100 maxwidth500 widthcentpercentminusx" type="text" name="email" class="flat" value="' . $object -> email . '">' ;
2020-05-21 15:05:19 +02:00
} else {
2019-10-23 21:27:29 +02:00
print '<input type="hidden" name="email" value="' . $object -> email . '">' ;
print $object -> email ;
}
print '</td></tr>' ;
2019-11-08 10:53:31 +01:00
if ( ! empty ( $conf -> socialnetworks -> enabled )) {
2019-09-14 12:00:39 +02:00
foreach ( $socialnetworks as $key => $value ) {
if ( $value [ 'active' ]) {
print '<tr><td>' . $langs -> trans ( $value [ 'label' ]) . '</td>' ;
print '<td>' ;
2021-03-12 15:34:31 +01:00
if ( ! empty ( $value [ 'icon' ])) {
2021-06-15 15:19:46 +02:00
print '<span class="fa ' . $value [ 'icon' ] . ' pictofixedwidth"></span>' ;
2021-03-12 15:34:31 +01:00
}
2019-11-08 10:53:31 +01:00
if ( $caneditfield && empty ( $object -> ldap_sid )) {
2021-06-15 15:19:46 +02:00
print '<input type="text" name="' . $key . '" class="flat maxwidth200" value="' . $object -> socialnetworks [ $key ] . '">' ;
2019-09-14 12:00:39 +02:00
} else {
print '<input type="hidden" name="' . $key . '" value="' . $object -> socialnetworks [ $key ] . '">' ;
print $object -> socialnetworks [ $key ];
}
print '</td></tr>' ;
} else {
// if social network is not active but value exist we do not want to loose it
print '<input type="hidden" name="' . $key . '" value="' . $object -> socialnetworks [ $key ] . '">' ;
}
2018-10-12 11:02:03 +02:00
}
}
2021-10-28 14:28:04 +02:00
print '</table><hr><table class="border centpercent">' ;
// Default warehouse
if ( ! empty ( $conf -> stock -> enabled ) && ! empty ( $conf -> global -> MAIN_DEFAULT_WAREHOUSE_USER )) {
print '<tr><td class="titlefield">' . $langs -> trans ( " DefaultWarehouse " ) . '</td><td>' ;
print $formproduct -> selectWarehouses ( $object -> fk_warehouse , 'fk_warehouse' , 'warehouseopen' , 1 );
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>' ;
2017-10-07 13:09:31 +02:00
print '</td></tr>' ;
}
2017-05-19 12:58:38 +02:00
2017-10-07 13:09:31 +02:00
// Accountancy code
2021-05-20 17:40:44 +02:00
if ( ! empty ( $conf -> accounting -> enabled )) {
2017-10-07 13:09:31 +02:00
print " <tr> " ;
2021-04-18 20:53:09 +02:00
print '<td class="titlefieldcreate">' . $langs -> trans ( " AccountancyCode " ) . '</td>' ;
2017-10-07 13:09:31 +02:00
print '<td>' ;
2021-02-26 13:18:40 +01:00
if ( $caneditfield ) {
2021-06-15 15:19:46 +02:00
print '<input type="text" class="flat maxwidth300" name="accountancy_code" value="' . $object -> accountancy_code . '">' ;
2020-05-21 15:05:19 +02:00
} else {
2018-04-13 09:05:17 +02:00
print '<input type="hidden" name="accountancy_code" value="' . $object -> accountancy_code . '">' ;
print $object -> accountancy_code ;
2017-10-07 13:09:31 +02:00
}
print '</td>' ;
print " </tr> " ;
}
2017-06-06 07:57:03 +02:00
2017-10-07 13:09:31 +02:00
// User color
2021-02-26 13:18:40 +01:00
if ( ! empty ( $conf -> agenda -> enabled )) {
2021-04-18 20:53:09 +02:00
print '<tr><td class="titlefieldcreate">' . $langs -> trans ( " ColorUser " ) . '</td>' ;
2017-10-07 13:09:31 +02:00
print '<td>' ;
2021-02-26 13:18:40 +01:00
if ( $caneditfield ) {
2020-04-10 10:59:32 +02:00
print $formother -> selectColor ( GETPOSTISSET ( 'color' ) ? GETPOST ( 'color' , 'alphanohtml' ) : $object -> color , 'color' , null , 1 , '' , 'hideifnotset' );
2019-11-08 10:53:31 +01:00
} else {
2018-11-14 18:29:15 +01:00
print $formother -> showColor ( $object -> color , '' );
}
2017-10-07 13:09:31 +02:00
print '</td></tr>' ;
}
// Photo
print '<tr>' ;
2021-04-18 20:53:09 +02:00
print '<td class="titlefieldcreate">' . $langs -> trans ( " Photo " ) . '</td>' ;
2017-10-07 13:09:31 +02:00
print '<td>' ;
2020-11-22 01:47:17 +01:00
print $form -> showphoto ( 'userphoto' , $object , 60 , 0 , $caneditfield , 'photowithmargin' , 'small' , 1 , 0 , 'user' , 1 );
2017-10-07 13:09:31 +02:00
print '</td>' ;
print '</tr>' ;
// Categories
2021-02-26 13:18:40 +01:00
if ( ! empty ( $conf -> categorie -> enabled ) && ! empty ( $user -> rights -> categorie -> lire )) {
2019-11-08 10:53:31 +01:00
print '<tr><td>' . $form -> editfieldkey ( 'Categories' , 'usercats' , '' , $object , 0 ) . '</td>' ;
2017-10-07 13:09:31 +02:00
print '<td>' ;
2021-06-15 15:19:46 +02:00
print img_picto ( '' , 'category' , 'class="pictofixedwidth"' );
2019-02-10 10:45:49 +01:00
$cate_arbo = $form -> select_all_categories ( Categorie :: TYPE_USER , null , null , null , null , 1 );
$c = new Categorie ( $db );
2017-10-07 13:09:31 +02:00
$cats = $c -> containing ( $object -> id , Categorie :: TYPE_USER );
foreach ( $cats as $cat ) {
$arrayselected [] = $cat -> id ;
}
2021-02-26 13:18:40 +01:00
if ( $caneditfield ) {
2019-02-10 10:45:49 +01:00
print $form -> multiselectarray ( 'usercats' , $cate_arbo , $arrayselected , '' , 0 , '' , 0 , '90%' );
2019-11-08 10:53:31 +01:00
} else {
2019-11-14 08:15:39 +01:00
print $form -> showCategories ( $object -> id , Categorie :: TYPE_USER , 1 );
2018-11-14 18:29:15 +01:00
}
2017-10-07 13:09:31 +02:00
print " </td></tr> " ;
}
2020-08-07 14:22:43 +02:00
// Default language
2021-02-26 13:18:40 +01:00
if ( ! empty ( $conf -> global -> MAIN_MULTILANGS )) {
2021-05-27 14:25:00 +02:00
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 " ;
2021-06-15 15:19:46 +02:00
print img_picto ( '' , 'language' , 'class="pictofixedwidth"' ) . $formadmin -> select_language ( $object -> lang , 'default_lang' , 0 , null , '1' , 0 , 0 , 'widthcentpercentminusx maxwidth300' );
2020-08-07 14:22:43 +02:00
print '</td>' ;
print '</tr>' ;
}
2017-10-07 13:09:31 +02:00
// Status
print '<tr><td>' . $langs -> trans ( " Status " ) . '</td>' ;
print '<td>' ;
print $object -> getLibStatut ( 4 );
print '</td></tr>' ;
// Company / Contact
2021-02-26 13:18:40 +01:00
if ( ! empty ( $conf -> societe -> enabled )) {
2020-01-07 14:55:31 +01:00
print '<tr><td>' . $langs -> trans ( " LinkToCompanyContact " ) . '</td>' ;
2017-10-07 13:09:31 +02:00
print '<td>' ;
2021-02-26 13:18:40 +01:00
if ( $object -> socid > 0 ) {
2017-10-07 13:09:31 +02:00
$societe = new Societe ( $db );
$societe -> fetch ( $object -> socid );
2019-01-27 11:55:16 +01:00
print $societe -> getNomUrl ( 1 , '' );
2021-02-26 13:18:40 +01:00
if ( $object -> contact_id ) {
2017-10-07 13:09:31 +02:00
$contact = new Contact ( $db );
2020-06-25 12:17:47 +02:00
$contact -> fetch ( $object -> contact_id );
print ' / <a href="' . DOL_URL_ROOT . '/contact/card.php?id=' . $object -> contact_id . '">' . img_object ( $langs -> trans ( " ShowContact " ), 'contact' ) . ' ' . dol_trunc ( $contact -> getFullName ( $langs ), 32 ) . '</a>' ;
2017-10-07 13:09:31 +02:00
}
2020-05-21 15:05:19 +02:00
} else {
2020-11-22 01:16:32 +01:00
print '<span class="opacitymedium hideonsmartphone">' . $langs -> trans ( " ThisUserIsNot " ) . '</span>' ;
2017-10-07 13:09:31 +02:00
}
2020-11-22 01:16:32 +01:00
print ' <span class="opacitymedium hideonsmartphone">(' . $langs -> trans ( " UseTypeFieldToChange " ) . ')</span>' ;
2017-10-07 13:09:31 +02:00
print '</td>' ;
print " </tr> \n " ;
}
// Module Adherent
2021-02-26 13:18:40 +01:00
if ( ! empty ( $conf -> adherent -> enabled )) {
2017-10-07 13:09:31 +02:00
$langs -> load ( " members " );
2020-01-07 14:55:31 +01:00
print '<tr><td>' . $langs -> trans ( " LinkedToDolibarrMember " ) . '</td>' ;
2017-10-07 13:09:31 +02:00
print '<td>' ;
2021-02-26 13:18:40 +01:00
if ( $object -> fk_member ) {
2019-11-08 10:53:31 +01:00
$adh = new Adherent ( $db );
2017-10-07 13:09:31 +02:00
$adh -> fetch ( $object -> fk_member );
2019-11-08 10:53:31 +01:00
$adh -> ref = $adh -> login ; // Force to show login instead of id
2017-10-07 13:09:31 +02:00
print $adh -> getNomUrl ( 1 );
2020-05-21 15:05:19 +02:00
} else {
2020-11-22 01:16:32 +01:00
print '<span class="opacitymedium hideonsmartphone">' . $langs -> trans ( " UserNotLinkedToMember " ) . '</span>' ;
2017-10-07 13:09:31 +02:00
}
print '</td>' ;
print " </tr> \n " ;
}
2009-05-07 01:30:49 +02:00
2020-09-07 10:18:17 +02:00
// Multicompany
// TODO check if user not linked with the current entity before change entity (thirdparty, invoice, etc.) !!
2021-02-26 13:18:40 +01:00
if ( ! empty ( $conf -> multicompany -> enabled ) && is_object ( $mc )) {
2020-09-07 10:18:17 +02:00
// This is now done with hook formObjectOptions. Keep this code for backward compatibility with old multicompany module
2021-02-26 13:18:40 +01:00
if ( ! method_exists ( $mc , 'formObjectOptions' )) {
if ( empty ( $conf -> multicompany -> transverse_mode ) && $conf -> entity == 1 && $user -> admin && ! $user -> entity ) {
2020-09-07 10:18:17 +02:00
print " <tr> " . '<td>' . $langs -> trans ( " Entity " ) . '</td>' ;
print " <td> " . $mc -> select_entities ( $object -> entity , 'entity' , '' , 0 , 1 , false , false , 1 ); // last parameter 1 means, show also a choice 0=>'all entities'
print " </td></tr> \n " ;
} else {
print '<input type="hidden" name="entity" value="' . $conf -> entity . '" />' ;
}
}
2018-07-05 22:15:55 +02:00
}
2017-08-25 13:25:34 +02:00
2017-10-07 13:09:31 +02:00
// Other attributes
2019-11-08 10:53:31 +01:00
$parameters = array ( 'colspan' => ' colspan="2"' );
2020-04-05 03:14:12 +02:00
//include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php'; // We do not use common tpl here because we need a special test on $caneditfield
2019-11-08 10:53:31 +01:00
$reshook = $hookmanager -> executeHooks ( 'formObjectOptions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
2017-10-07 13:09:31 +02:00
print $hookmanager -> resPrint ;
2021-02-26 13:18:40 +01:00
if ( empty ( $reshook )) {
2020-04-05 03:14:12 +02:00
if ( $caneditfield ) {
2019-01-27 11:55:16 +01:00
print $object -> showOptionals ( $extrafields , 'edit' );
2019-11-08 10:53:31 +01:00
} else {
2019-01-27 11:55:16 +01:00
print $object -> showOptionals ( $extrafields , 'view' );
2018-11-14 18:29:15 +01:00
}
2017-10-07 13:09:31 +02:00
}
2012-12-12 11:57:56 +01:00
2017-10-07 13:09:31 +02:00
// Signature
2019-02-16 10:29:15 +01:00
print '<tr><td class="tdtop">' . $langs -> trans ( " Signature " ) . '</td>' ;
2017-10-07 13:09:31 +02:00
print '<td>' ;
2021-02-26 13:18:40 +01:00
if ( $caneditfield ) {
2017-10-07 13:09:31 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php' ;
2019-11-08 10:53:31 +01:00
$doleditor = new DolEditor ( 'signature' , $object -> signature , '' , 138 , 'dolibarr_notes' , 'In' , false , true , empty ( $conf -> global -> FCKEDITOR_ENABLE_USERSIGN ) ? 0 : 1 , ROWS_4 , '90%' );
2017-10-07 13:09:31 +02:00
print $doleditor -> Create ( 1 );
2020-05-21 15:05:19 +02:00
} else {
2017-10-07 13:09:31 +02:00
print dol_htmlentitiesbr ( $object -> signature );
}
print '</td></tr>' ;
2017-06-06 07:57:03 +02:00
2017-12-19 16:16:31 +01:00
2021-04-18 20:53:09 +02:00
print '</table>' ;
print '<hr>' ;
print '<table class="border centpercent">' ;
2017-12-19 16:16:31 +01:00
// TODO Move this into tab RH (HierarchicalResponsible must be on both tab)
2020-09-07 10:18:17 +02:00
// Position/Job
2021-04-18 20:53:09 +02:00
print '<tr><td class="titlefieldcreate">' . $langs -> trans ( " PostOrFunction " ) . '</td>' ;
2020-09-07 10:18:17 +02:00
print '<td>' ;
2021-02-26 13:18:40 +01:00
if ( $caneditfield ) {
2021-06-15 15:24:12 +02:00
print '<input type="text" class="minwidth300 maxwidth500" name="job" value="' . dol_escape_htmltag ( $object -> job ) . '">' ;
2020-09-07 10:18:17 +02:00
} else {
2020-09-19 03:25:25 +02:00
print '<input type="hidden" name="job" value="' . dol_escape_htmltag ( $object -> job ) . '">' ;
print dol_escape_htmltag ( $object -> job );
2020-09-07 10:18:17 +02:00
}
print '</td></tr>' ;
2021-10-28 14:28:04 +02:00
// Weeklyhours
print '<tr><td>' . $langs -> trans ( " WeeklyHours " ) . '</td>' ;
print '<td>' ;
if ( $caneditfield ) {
print '<input size="8" type="text" name="weeklyhours" value="' . price2num ( GETPOST ( 'weeklyhours' ) ? GETPOST ( 'weeklyhours' ) : $object -> weeklyhours ) . '">' ;
} else {
print price2num ( $object -> weeklyhours );
}
print '</td>' ;
print " </tr> \n " ;
// Sensitive salary/value information
if (( empty ( $user -> socid ) && in_array ( $id , $childids )) // A user can always see salary/value information for its subordinates
2021-06-15 14:29:07 +02:00
|| ( ! empty ( $conf -> salaries -> enabled ) && ! empty ( $user -> rights -> salaries -> readall ))
2021-02-26 13:18:40 +01:00
|| ( ! empty ( $conf -> hrm -> enabled ) && ! empty ( $user -> rights -> hrm -> employee -> read ))) {
2021-10-28 14:28:04 +02:00
$langs -> load ( " salaries " );
// Salary
print '<tr><td>' . $langs -> trans ( " Salary " ) . '</td>' ;
print '<td>' ;
print img_picto ( '' , 'salary' , 'class="pictofixedwidth paddingright"' ) . '<input size="8" type="text" name="salary" value="' . price2num ( GETPOST ( 'salary' ) ? GETPOST ( 'salary' ) : $object -> salary ) . '">' ;
print '</td>' ;
print " </tr> \n " ;
2017-12-19 16:16:31 +01:00
// THM
print '<tr><td>' ;
2019-11-08 10:53:31 +01:00
$text = $langs -> trans ( " THM " );
2017-12-19 16:16:31 +01:00
print $form -> textwithpicto ( $text , $langs -> trans ( " THMDescription " ), 1 , 'help' , 'classthm' );
print '</td>' ;
print '<td>' ;
2019-11-08 10:53:31 +01:00
if ( $caneditfield ) {
print '<input size="8" type="text" name="thm" value="' . price2num ( GETPOST ( 'thm' ) ? GETPOST ( 'thm' ) : $object -> thm ) . '">' ;
} else {
print ( $object -> thm != '' ? price ( $object -> thm , '' , $langs , 1 , - 1 , - 1 , $conf -> currency ) : '' );
2018-11-14 18:29:15 +01:00
}
2017-12-19 16:16:31 +01:00
print '</td>' ;
print " </tr> \n " ;
// TJM
print '<tr><td>' ;
2019-11-08 10:53:31 +01:00
$text = $langs -> trans ( " TJM " );
2017-12-19 16:16:31 +01:00
print $form -> textwithpicto ( $text , $langs -> trans ( " TJMDescription " ), 1 , 'help' , 'classthm' );
print '</td>' ;
print '<td>' ;
2021-02-26 13:18:40 +01:00
if ( $caneditfield ) {
2019-11-08 10:53:31 +01:00
print '<input size="8" type="text" name="tjm" value="' . price2num ( GETPOST ( 'tjm' ) ? GETPOST ( 'tjm' ) : $object -> tjm ) . '">' ;
} else {
print ( $object -> tjm != '' ? price ( $object -> tjm , '' , $langs , 1 , - 1 , - 1 , $conf -> currency ) : '' );
2018-11-14 18:29:15 +01:00
}
2017-12-19 16:16:31 +01:00
print '</td>' ;
print " </tr> \n " ;
}
// Date employment
print '<tr><td>' . $langs -> trans ( " DateEmployment " ) . '</td>' ;
print '<td>' ;
2021-02-26 13:18:40 +01:00
if ( $caneditfield ) {
2020-09-21 18:44:20 +02:00
print $form -> selectDate ( $dateemployment ? $dateemployment : $object -> dateemployment , 'dateemployment' , 0 , 0 , 1 , 'formdateemployment' , 1 , 1 );
2019-11-08 10:53:31 +01:00
} else {
2018-11-14 18:29:15 +01:00
print dol_print_date ( $object -> dateemployment , 'day' );
}
2020-09-21 18:44:20 +02:00
2021-02-26 13:18:40 +01:00
if ( $dateemployment && $dateemploymentend ) {
print ' - ' ;
}
2020-09-21 18:44:20 +02:00
2021-02-26 13:18:40 +01:00
if ( $caneditfield ) {
2020-09-21 18:44:20 +02:00
print $form -> selectDate ( $dateemploymentend ? $dateemploymentend : $object -> dateemploymentend , 'dateemploymentend' , 0 , 0 , 1 , 'formdateemploymentend' , 1 , 0 );
} else {
print dol_print_date ( $object -> dateemploymentend , 'day' );
}
2017-12-19 16:16:31 +01:00
print '</td>' ;
print " </tr> \n " ;
// Date birth
2020-09-21 18:44:20 +02:00
print '<tr><td>' . $langs -> trans ( " DateOfBirth " ) . '</td>' ;
2017-12-19 16:16:31 +01:00
print '<td>' ;
2020-09-21 18:44:20 +02:00
if ( $caneditfield ) {
echo $form -> selectDate ( $dateofbirth ? $dateofbirth : $object -> birth , 'dateofbirth' , 0 , 0 , 1 , 'updateuser' , 1 , 0 );
2019-11-08 10:53:31 +01:00
} else {
2018-11-14 18:29:15 +01:00
print dol_print_date ( $object -> birth , 'day' );
}
2017-12-19 16:16:31 +01:00
print '</td>' ;
print " </tr> \n " ;
2017-10-07 13:09:31 +02:00
print '</table>' ;
2011-06-11 16:14:27 +02:00
2020-10-27 18:19:31 +01:00
print dol_get_fiche_end ();
2015-05-04 11:41:30 +02:00
2019-02-16 10:29:15 +01:00
print '<div class="center">' ;
2020-11-19 20:23:38 +01:00
print '<input value="' . $langs -> trans ( " Save " ) . '" class="button button-save" type="submit" name="save">' ;
2017-10-07 13:09:31 +02:00
print ' ' ;
2020-11-23 15:12:52 +01:00
print '<input value="' . $langs -> trans ( " Cancel " ) . '" class="button button-cancel" type="submit" name="cancel">' ;
2017-10-07 13:09:31 +02:00
print '</div>' ;
2008-08-28 14:08:02 +02:00
2017-10-07 13:09:31 +02:00
print '</form>' ;
}
2008-08-28 14:08:02 +02:00
2021-02-26 13:18:40 +01:00
if ( $action != 'edit' && $action != 'presend' ) {
2017-10-07 13:09:31 +02:00
print '<div class="fichecenter"><div class="fichehalfleft">' ;
2021-05-19 12:13:21 +02:00
// Generated documents
2017-10-07 13:09:31 +02:00
$filename = dol_sanitizeFileName ( $object -> ref );
2019-11-08 10:53:31 +01:00
$filedir = $conf -> user -> dir_output . " / " . dol_sanitizeFileName ( $object -> ref );
$urlsource = $_SERVER [ " PHP_SELF " ] . " ?id= " . $object -> id ;
2017-10-18 19:51:29 +02:00
$genallowed = $user -> rights -> user -> user -> lire ;
$delallowed = $user -> rights -> user -> user -> creer ;
2017-06-06 07:57:03 +02:00
2021-05-20 17:40:44 +02:00
print $formfile -> showdocuments ( 'user' , $filename , $filedir , $urlsource , $genallowed , $delallowed , $object -> model_pdf , 1 , 0 , 0 , 28 , 0 , '' , 0 , '' , empty ( $soc -> default_lang ) ? '' : $soc -> default_lang );
2017-10-07 13:09:31 +02:00
$somethingshown = $formfile -> numoffiles ;
2017-06-06 07:57:03 +02:00
2017-10-07 13:09:31 +02:00
// Show links to link elements
$linktoelem = $form -> showLinkToObjectBlock ( $object , null , null );
$somethingshown = $form -> showLinkedObjectBlock ( $object , $linktoelem );
2017-06-06 07:57:03 +02:00
2021-10-23 17:18:35 +02:00
print '</div><div class="fichehalfright">' ;
2017-06-06 07:57:03 +02:00
2017-10-07 13:09:31 +02:00
// List of actions on element
2019-11-08 10:53:31 +01:00
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php' ;
2017-10-07 13:09:31 +02:00
$formactions = new FormActions ( $db );
$somethingshown = $formactions -> showactions ( $object , 'user' , $socid , 1 );
2017-06-06 07:57:03 +02:00
2021-10-23 17:18:35 +02:00
print '</div></div>' ;
2017-10-07 13:09:31 +02:00
}
2017-06-06 07:57:03 +02:00
2021-02-26 13:18:40 +01:00
if ( ! empty ( $conf -> ldap -> enabled ) && ! empty ( $object -> ldap_sid )) {
2021-10-28 15:40:05 +02:00
$ldap -> unbind ();
2021-02-26 13:18:40 +01:00
}
2017-10-07 13:09:31 +02:00
}
2002-05-06 21:10:48 +02:00
}
2021-02-26 13:18:40 +01:00
if ( ! empty ( $conf -> api -> enabled ) && ! empty ( $conf -> use_javascript_ajax )) {
2017-10-07 13:09:31 +02:00
print " \n " . '<script type="text/javascript">' ;
print ' $ ( document ) . ready ( function () {
2015-05-29 16:05:52 +02:00
$ ( " #generate_api_key " ) . click ( function () {
$ . get ( " '.DOL_URL_ROOT.'/core/ajax/security.php " , {
action : \ ' getrandompassword\ ' ,
generic : true
},
function ( token ) {
$ ( " #api_key " ) . val ( token );
});
});
}); ' ;
2017-10-07 13:09:31 +02:00
print '</script>' ;
2015-05-29 16:05:52 +02:00
}
2002-05-06 21:10:48 +02:00
2018-08-04 15:58:05 +02:00
// End of page
2011-08-27 16:24:16 +02:00
llxFooter ();
2012-07-10 13:20:53 +02:00
$db -> close ();