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 >
2015-02-23 14:44:24 +01:00
* Copyright ( C ) 2004 - 2015 Laurent Destailleur < eldy @ users . sourceforge . net >
2004-12-22 21:50:38 +01:00
* Copyright ( C ) 2004 Eric Seigne < eric . seigne @ ryxeo . com >
2018-10-27 14:43:12 +02:00
* Copyright ( C ) 2005 - 2018 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 >
2019-02-16 10:29:15 +01:00
* Copyright ( C ) 2018 - 2019 Frédéric France < frederic . france @ netlogic . fr >
* 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
2011-08-01 01:19:04 +02:00
* along with this program . If not , see < http :// 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' ;
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' ;
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' ;
2012-08-22 23:11:24 +02: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' ;
2016-02-13 10:42:45 +01:00
if ( ! empty ( $conf -> categorie -> enabled )) require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php' ;
2019-02-15 17:12:39 +01:00
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-01-27 11:55:16 +01:00
$id = GETPOST ( 'id' , 'int' );
$action = GETPOST ( 'action' , 'aZ09' );
$mode = GETPOST ( 'mode' , 'alpha' );
$confirm = GETPOST ( 'confirm' , 'alpha' );
$subaction = GETPOST ( 'subaction' , 'alpha' );
$group = GETPOST ( " group " , " int " , 3 );
$cancel = GETPOST ( 'cancel' , 'alpha' );
$contextpage = GETPOST ( 'contextpage' , 'aZ' ) ? GETPOST ( 'contextpage' , 'aZ' ) : 'useracard' ; // To manage different context of search
2011-11-02 20:17:55 +01:00
2009-07-04 19:29:26 +02:00
// Define value to know what current user can do on users
2012-07-10 13:20:53 +02: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 );
2011-03-14 11:37:23 +01:00
$canreadgroup = $canreaduser ;
$caneditgroup = $canedituser ;
2010-11-08 12:40:52 +01:00
if ( ! empty ( $conf -> global -> MAIN_USE_ADVANCED_PERMS ))
{
2017-10-07 13:09:31 +02: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
2009-07-04 19:29:26 +02:00
// Define value to know what current user can do on properties of edited user
2011-10-27 10:41:29 +02:00
if ( $id )
2006-06-14 00:50:36 +02:00
{
2017-10-07 13:09:31 +02:00
// $user est le user qui edite, $id est l'id de l'utilisateur edite
$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
2009-08-06 15:07:25 +02:00
$socid = 0 ;
2010-11-10 11:53:39 +01:00
if ( $user -> societe_id > 0 ) $socid = $user -> societe_id ;
$feature2 = 'user' ;
2019-01-15 12:18:04 +01:00
2019-01-16 19:13:21 +01:00
$result = restrictedArea ( $user , 'user' , $id , 'user&user' , $feature2 );
2019-01-15 12:18:04 +01:00
2011-10-27 10:41:29 +02:00
if ( $user -> id <> $id && ! $canreaduser ) accessforbidden ();
2005-08-23 13:40:19 +02:00
2018-05-26 16:24:54 +02:00
// Load translation files required by page
2019-02-15 05:24:25 +01:00
$langs -> loadLangs ( array ( 'users' , 'companies' , 'ldap' , 'admin' , 'hrm' , 'stocks' ));
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
$extralabels = $extrafields -> fetch_name_optionals_label ( $object -> table_element );
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
2018-04-02 16:29:58 +02:00
$hookmanager -> initHooks ( array ( 'usercard' , 'globalcard' ));
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
*/
2003-08-10 14:44:43 +02:00
2017-11-04 15:40:35 +01:00
$parameters = array ( 'id' => $id , 'socid' => $socid , 'group' => $group , 'caneditgroup' => $caneditgroup );
2019-01-27 11:55:16 +01:00
$reshook = $hookmanager -> executeHooks ( 'doActions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by some hooks
2015-09-16 09:37:49 +02: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 )) {
2011-06-29 12:23:32 +02:00
2015-10-15 16:16:50 +02:00
if ( $action == 'confirm_disable' && $confirm == " yes " && $candisableuser ) {
if ( $id <> $user -> id ) {
$object -> fetch ( $id );
$object -> setstatus ( 0 );
header ( " Location: " . $_SERVER [ 'PHP_SELF' ] . '?id=' . $id );
exit ;
}
}
if ( $action == 'confirm_enable' && $confirm == " yes " && $candisableuser ) {
$error = 0 ;
2015-09-16 09:37:49 +02:00
2015-10-15 16:16:50 +02:00
if ( $id <> $user -> id ) {
$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 ) {
$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
2018-12-22 18:09:26 +01:00
if ( $action == 'confirm_delete' && $confirm == " yes " && $candisableuser )
{
if ( $id <> $user -> id )
{
if ( ! GETPOSTISSET ( 'token' ))
{
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 );
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
2015-10-15 16:16:50 +02:00
if ( ! $_POST [ " lastname " ]) {
$error ++ ;
2015-12-21 14:43:21 +01:00
setEventMessages ( $langs -> trans ( " NameNotDefined " ), null , 'errors' );
2015-10-15 16:16:50 +02:00
$action = " create " ; // Go back to create page
}
if ( ! $_POST [ " login " ]) {
$error ++ ;
2015-12-21 14:43:21 +01:00
setEventMessages ( $langs -> trans ( " LoginNotDefined " ), null , 'errors' );
2015-10-15 16:16:50 +02:00
$action = " create " ; // Go back to create page
}
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 ) {
$error ++ ;
2015-12-21 14:43:21 +01:00
setEventMessages ( $langs -> trans ( " YourQuotaOfUsersIsReached " ), null , 'errors' );
2015-10-15 16:16:50 +02:00
$action = " create " ; // Go back to create page
}
}
2011-06-29 12:23:32 +02:00
2015-10-15 16:16:50 +02:00
if ( ! $error ) {
$object -> lastname = GETPOST ( " lastname " , 'alpha' );
$object -> firstname = GETPOST ( " firstname " , 'alpha' );
$object -> login = GETPOST ( " login " , 'alpha' );
$object -> api_key = GETPOST ( " api_key " , 'alpha' );
$object -> gender = GETPOST ( " gender " , 'alpha' );
2017-10-06 12:08:01 +02:00
$birth = dol_mktime ( 0 , 0 , 0 , GETPOST ( 'birthmonth' ), GETPOST ( 'birthday' ), GETPOST ( 'birthyear' ));
$object -> birth = $birth ;
2015-10-15 16:16:50 +02:00
$object -> admin = GETPOST ( " admin " , 'alpha' );
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-09-12 20:03:28 +02:00
//$object->skype = GETPOST("skype", 'alphanohtml');
//$object->twitter = GETPOST("twitter", 'alphanohtml');
//$object->facebook = GETPOST("facebook", 'alphanohtml');
//$object->linkedin = GETPOST("linkedin", 'alphanohtml');
$object -> socialnetworks = array ();
if ( ! empty ( $conf -> socialnetworks -> enabled )) {
foreach ( $socialnetworks as $key => $value ) {
2019-09-14 11:26:31 +02:00
if ( ! $value [ 'active' ]) break ;
2019-09-12 20:03:28 +02:00
$object -> socialnetworks [ $key ] = GETPOST ( $key , 'alphanohtml' );
}
}
2018-03-30 07:36:23 +02:00
$object -> email = preg_replace ( '/\s+/' , '' , GETPOST ( " email " , 'alpha' ));
2015-10-15 16:16:50 +02:00
$object -> job = GETPOST ( " job " , 'alpha' );
2018-12-22 17:08:55 +01:00
$object -> signature = GETPOST ( " signature " , 'none' );
$object -> accountancy_code = GETPOST ( " accountancy_code " , 'alphanohtml' );
$object -> note = GETPOST ( " note " , 'none' );
$object -> ldap_sid = GETPOST ( " ldap_sid " , 'alphanohtml' );
$object -> fk_user = GETPOST ( " fk_user " , 'int' ) > 0 ? GETPOST ( " fk_user " , 'int' ) : 0 ;
$object -> employee = GETPOST ( 'employee' , 'alphanohtml' );
$object -> thm = GETPOST ( " thm " , 'alphanohtml' ) != '' ? GETPOST ( " thm " , 'alphanohtml' ) : '' ;
$object -> tjm = GETPOST ( " tjm " , 'alphanohtml' ) != '' ? GETPOST ( " tjm " , 'alphanohtml' ) : '' ;
$object -> salary = GETPOST ( " salary " , 'alphanohtml' ) != '' ? GETPOST ( " salary " , 'alphanohtml' ) : '' ;
$object -> salaryextra = GETPOST ( " salaryextra " , 'alphanohtml' ) != '' ? GETPOST ( " salaryextra " , 'alphanohtml' ) : '' ;
$object -> weeklyhours = GETPOST ( " weeklyhours " , 'alphanohtml' ) != '' ? GETPOST ( " weeklyhours " , 'alphanohtml' ) : '' ;
$object -> color = GETPOST ( " color " , 'alphanohtml' ) != '' ? GETPOST ( " color " , 'alphanohtml' ) : '' ;
2016-09-28 11:23:00 +02:00
$dateemployment = dol_mktime ( 0 , 0 , 0 , GETPOST ( 'dateemploymentmonth' ), GETPOST ( 'dateemploymentday' ), GETPOST ( 'dateemploymentyear' ));
$object -> dateemployment = $dateemployment ;
2015-10-15 16:16:50 +02:00
2018-05-12 18:05:06 +02:00
$dateemploymentend = dol_mktime ( 0 , 0 , 0 , GETPOST ( 'dateemploymentendmonth' ), GETPOST ( 'dateemploymentendday' ), GETPOST ( 'dateemploymentendyear' ));
$object -> dateemploymentend = $dateemploymentend ;
2019-02-15 05:24:25 +01:00
$object -> fk_warehouse = GETPOST ( 'fk_warehouse' , 'int' );
2015-10-15 16:16:50 +02:00
// Fill array 'array_options' with data from add form
$ret = $extrafields -> setOptionalsFromPost ( $extralabels , $object );
if ( $ret < 0 ) {
$error ++ ;
}
2011-06-29 12:23:32 +02:00
2015-10-15 16:16:50 +02:00
// Set entity property
$entity = GETPOST ( 'entity' , 'int' );
2017-06-06 07:57:03 +02:00
if ( ! empty ( $conf -> multicompany -> enabled )) {
if ( GETPOST ( 'superadmin' , 'int' )) {
2015-10-15 16:16:50 +02:00
$object -> entity = 0 ;
} else {
2017-06-06 07:57:03 +02: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 ) {
2017-06-06 07:57:03 +02:00
if ( GETPOST ( 'password' )) {
$object -> setPassword ( $user , GETPOST ( 'password' ));
2015-10-15 16:16:50 +02:00
}
2019-02-03 14:29:45 +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 ;
2016-03-17 09:22:12 +01:00
}
2015-12-21 14:43:21 +01: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' );
2015-10-15 16:16:50 +02:00
$action = " create " ; // Go back to create page
}
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
2017-11-04 15:40:35 +01:00
if (( $action == 'addgroup' || $action == 'removegroup' ) && $caneditgroup )
2015-10-15 16:16:50 +02:00
{
if ( $group )
{
$editgroup = new UserGroup ( $db );
$editgroup -> fetch ( $group );
$editgroup -> oldcopy = clone $editgroup ;
$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 ) {
header ( " Location: " . $_SERVER [ 'PHP_SELF' ] . '?id=' . $id );
exit ;
2016-03-17 09:22:12 +01: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
2017-06-06 07:57:03 +02:00
if ( $action == 'update' && ! $cancel )
2016-06-25 18:48:50 +02:00
{
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
2015-10-15 16:16:50 +02:00
if ( $caneditfield ) // Case we can edit all field
{
$error = 0 ;
2012-12-12 11:57:56 +01:00
2019-08-16 16:41:53 +02:00
if ( ! GETPOST ( " lastname " , 'alpha' )) {
2016-03-17 09:22:12 +01:00
setEventMessages ( $langs -> trans ( " NameNotDefined " ), null , 'errors' );
$action = " edit " ; // Go back to create page
$error ++ ;
}
2019-08-16 16:41:53 +02:00
if ( ! GETPOST ( " login " , 'alpha' )) {
2016-03-17 09:22:12 +01:00
setEventMessages ( $langs -> trans ( " LoginNotDefined " ), null , 'errors' );
$action = " edit " ; // Go back to create page
$error ++ ;
}
2011-06-29 12:23:32 +02:00
2017-06-06 07:57:03 +02:00
if ( ! $error )
2017-02-28 11:16:07 +01:00
{
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 ();
$object -> lastname = GETPOST ( " lastname " , 'alpha' );
$object -> firstname = GETPOST ( " firstname " , 'alpha' );
$object -> login = GETPOST ( " login " , 'alpha' );
$object -> gender = GETPOST ( " gender " , 'alpha' );
2017-10-06 12:08:01 +02:00
$birth = dol_mktime ( 0 , 0 , 0 , GETPOST ( 'birthmonth' ), GETPOST ( 'birthday' ), GETPOST ( 'birthyear' ));
$object -> birth = $birth ;
2019-01-27 11:55:16 +01:00
$object -> pass = GETPOST ( " password " , 'none' );
2017-02-28 11:16:07 +01:00
$object -> api_key = ( GETPOST ( " api_key " , 'alpha' )) ? GETPOST ( " api_key " , 'alpha' ) : $object -> api_key ;
if ( ! empty ( $user -> admin )) $object -> admin = GETPOST ( " admin " ); // 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' );
2019-09-12 20:03:28 +02:00
//$object->skype = GETPOST("skype", 'alpha');
//$object->twitter = GETPOST("twitter", 'alpha');
//$object->facebook = GETPOST("facebook", 'alpha');
//$object->linkedin = GETPOST("linkedin", 'alpha');
$object -> socialnetworks = array ();
if ( ! empty ( $conf -> socialnetworks -> enabled )) {
foreach ( $socialnetworks as $key => $value ) {
2019-09-14 11:26:31 +02:00
if ( ! $value [ 'active' ]) break ;
2019-09-12 20:03:28 +02:00
$object -> socialnetworks [ $key ] = GETPOST ( $key , 'alpha' );
}
}
2018-03-30 07:36:23 +02:00
$object -> email = preg_replace ( '/\s+/' , '' , GETPOST ( " email " , 'alpha' ));
2017-02-28 11:16:07 +01:00
$object -> job = GETPOST ( " job " , 'alpha' );
2019-01-27 11:55:16 +01:00
$object -> signature = GETPOST ( " signature " , 'none' );
$object -> accountancy_code = GETPOST ( " accountancy_code " , 'alpha' );
$object -> openid = GETPOST ( " openid " , 'alpha' );
$object -> fk_user = GETPOST ( " fk_user " , 'int' ) > 0 ? GETPOST ( " fk_user " , 'int' ) : 0 ;
$object -> employee = GETPOST ( 'employee' , 'int' );
$object -> thm = GETPOST ( " thm " , 'alphanohtml' ) != '' ? GETPOST ( " thm " , 'alphanohtml' ) : '' ;
$object -> tjm = GETPOST ( " tjm " , 'alphanohtml' ) != '' ? GETPOST ( " tjm " , 'alphanohtml' ) : '' ;
$object -> salary = GETPOST ( " salary " , 'alphanohtml' ) != '' ? GETPOST ( " salary " , 'alphanohtml' ) : '' ;
$object -> salaryextra = GETPOST ( " salaryextra " , 'alphanohtml' ) != '' ? GETPOST ( " salaryextra " , 'alphanohtml' ) : '' ;
$object -> weeklyhours = GETPOST ( " weeklyhours " , 'alphanohtml' ) != '' ? GETPOST ( " weeklyhours " , 'alphanohtml' ) : '' ;
$object -> color = GETPOST ( " color " , 'alpha' ) != '' ? GETPOST ( " color " , 'alpha' ) : '' ;
$dateemployment = dol_mktime ( 0 , 0 , 0 , GETPOST ( 'dateemploymentmonth' , 'int' ), GETPOST ( 'dateemploymentday' , 'int' ), GETPOST ( 'dateemploymentyear' , 'int' ));
2017-02-28 11:16:07 +01:00
$object -> dateemployment = $dateemployment ;
2019-01-27 11:55:16 +01:00
$dateemploymentend = dol_mktime ( 0 , 0 , 0 , GETPOST ( 'dateemploymentendmonth' , 'int' ), GETPOST ( 'dateemploymentendday' , 'int' ), GETPOST ( 'dateemploymentendyear' , 'int' ));
2018-05-12 18:05:06 +02:00
$object -> dateemploymentend = $dateemploymentend ;
2019-02-27 13:48:13 +01:00
2019-02-27 13:37:53 +01:00
if ( ! empty ( $conf -> stock -> enabled ))
{
$object -> fk_warehouse = GETPOST ( 'fk_warehouse' , 'int' );
}
2019-02-27 13:48:13 +01:00
2017-02-28 11:16:07 +01:00
if ( ! empty ( $conf -> multicompany -> enabled ))
{
if ( ! empty ( $_POST [ " superadmin " ]))
2016-03-17 09:22:12 +01:00
{
2017-02-28 11:16:07 +01:00
$object -> entity = 0 ;
}
2019-01-27 10:49:34 +01:00
elseif ( ! empty ( $conf -> global -> MULTICOMPANY_TRANSVERSE_MODE ))
2017-02-28 11:16:07 +01:00
{
$object -> entity = 1 ; // all users in master entity
2016-03-17 09:22:12 +01:00
}
else
{
$object -> entity = ( ! GETPOST ( 'entity' , 'int' ) ? 0 : GETPOST ( 'entity' , 'int' ));
}
2017-02-28 11:16:07 +01:00
}
else
{
$object -> entity = ( ! GETPOST ( 'entity' , 'int' ) ? 0 : GETPOST ( 'entity' , 'int' ));
}
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
$ret = $extrafields -> setOptionalsFromPost ( $extralabels , $object );
if ( $ret < 0 ) {
$error ++ ;
}
2013-01-10 20:07:44 +01:00
2017-02-28 11:16:07 +01:00
if ( GETPOST ( 'deletephoto' )) {
$object -> photo = '' ;
}
2019-05-10 20:09:41 +02:00
if ( ! empty ( $_FILES [ 'photo' ][ 'name' ]))
{
$isimage = image_format_supported ( $_FILES [ 'photo' ][ 'name' ]);
if ( $isimage > 0 )
{
$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' );
}
else
{
setEventMessages ( $object -> error , $object -> errors , 'errors' );
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' );
2016-03-17 09:22:12 +01:00
2017-02-28 11:16:07 +01:00
if ( $contactid > 0 ) {
$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 " ;
$sql .= " SET fk_socpeople= " . $db -> escape ( $contactid );
if ( ! empty ( $contact -> socid )) {
$sql .= " , fk_soc= " . $db -> escape ( $contact -> socid );
2016-03-17 09:22:12 +01:00
}
2017-02-28 11:16:07 +01:00
$sql .= " WHERE rowid= " . $object -> id ;
} else {
$sql = " UPDATE " . MAIN_DB_PREFIX . " user " ;
$sql .= " SET fk_socpeople=NULL, fk_soc=NULL " ;
$sql .= " WHERE rowid= " . $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 ) {
$error ++ ;
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 )) {
if ( GETPOST ( 'deletephoto' ) && $object -> photo ) {
2018-12-01 16:55:42 +01:00
$fileimg = $conf -> user -> dir_output . '/' . get_exdir ( 0 , 0 , 0 , 0 , $object , 'user' ) . '/' . $object -> id . '/logos/' . $object -> photo ;
$dirthumbs = $conf -> user -> dir_output . '/' . get_exdir ( 0 , 0 , 0 , 0 , $object , 'user' ) . '/' . $object -> id . '/logos/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' ])) {
2018-12-01 16:55:42 +01:00
$dir = $conf -> user -> dir_output . '/' . get_exdir ( 0 , 0 , 0 , 0 , $object , 'user' ) . '/' . $object -> id ;
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 {
$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
2017-10-07 13:09:31 +02:00
if ( ! $error && ! count ( $object -> errors ))
{
// 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 " ];
if ( $login && $login == $object -> oldcopy -> login && $object -> oldcopy -> login != $object -> login ) // Current user has changed its login
{
$error ++ ;
$langs -> load ( " errors " );
setEventMessages ( $langs -> transnoentitiesnoconv ( " WarningYourLoginWasModifiedPleaseLogin " ), null , 'warnings' );
2016-03-18 11:54:14 +01:00
}
2017-02-28 11:16:07 +01: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
}
}
2016-03-17 23:58:04 +01:00
else
{
2017-10-07 13:09:31 +02:00
if ( $caneditpassword ) // Case we can edit only password
{
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
2017-10-07 13:09:31 +02:00
$object -> oldcopy = clone $object ;
2017-06-06 07:57:03 +02:00
2017-10-07 13:09:31 +02:00
$ret = $object -> setPassword ( $user , GETPOST ( " password " ));
if ( $ret < 0 )
{
setEventMessages ( $object -> error , $object -> errors , 'errors' );
}
}
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 );
$newpassword = $object -> setPassword ( $user , '' );
if ( $newpassword < 0 ) {
// Echec
setEventMessages ( $langs -> trans ( " ErrorFailedToSetNewPassword " ), null , 'errors' );
} else {
// Succes
if ( $action == 'confirm_passwordsend' && $confirm == 'yes' ) {
if ( $object -> send_password ( $user , $newpassword ) > 0 )
{
setEventMessages ( $langs -> trans ( " PasswordChangedAndSentTo " , $object -> email ), null , 'mesgs' );
}
else
{
setEventMessages ( $object -> error , $object -> errors , 'errors' );
}
}
else
{
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
2017-10-07 13:09:31 +02:00
if ( $action == 'adduserldap' ) {
$selecteduser = $_POST [ 'users' ];
$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 ];
}
}
}
else
{
setEventMessages ( $ldap -> error , $ldap -> errors , 'errors' );
}
}
// Actions to send emails
$trigger_name = 'USER_SENTBYMAIL' ;
$paramname = 'id' ; // Name of param key to open the card
$mode = 'emailfromuser' ;
2018-12-17 15:48:27 +01:00
$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 ;
$permissioncreate = $user -> rights -> user -> user -> creer ;
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 );
2014-10-16 06:20:54 +02:00
$formother = new FormOther ( $db );
2015-11-18 06:34:08 +01:00
$formcompany = new FormCompany ( $db );
2017-01-06 16:44:09 +01:00
$formfile = new FormFile ( $db );
2019-02-15 17:12:39 +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
2017-06-06 07:57:03 +02:00
if ( $action == 'create' || $action == 'adduserldap' )
2002-12-13 17:51:03 +01:00
{
2017-10-07 13:09:31 +02:00
/* ************************************************************************** */
/* */
/* Affichage fiche en mode creation */
/* */
/* ************************************************************************** */
2011-06-29 12:23:32 +02:00
2017-10-07 13:09:31 +02:00
print load_fiche_titre ( $langs -> trans ( " NewUser " ));
2011-06-29 12:23:32 +02:00
2017-10-07 13:09:31 +02:00
print $langs -> trans ( " CreateInternalUserDesc " ) . " <br> \n " ;
print " <br> " ;
2011-06-29 12:23:32 +02:00
2015-05-04 11:41:30 +02:00
2017-10-07 13:09:31 +02:00
if ( ! empty ( $conf -> ldap -> enabled ) && ( isset ( $conf -> global -> LDAP_SYNCHRO_ACTIVE ) && $conf -> global -> LDAP_SYNCHRO_ACTIVE == 'ldap2dolibarr' ))
{
/*
2011-06-29 12:23:32 +02:00
* Affiche formulaire d 'ajout d' un compte depuis LDAP
* si on est en synchro LDAP vers Dolibarr
*/
2017-10-07 13:09:31 +02:00
$ldap = new Ldap ();
$result = $ldap -> connect_bind ();
if ( $result >= 0 )
{
$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
$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
2017-10-07 13:09:31 +02:00
if ( is_array ( $ldapusers ))
{
$liste = array ();
foreach ( $ldapusers as $key => $ldapuser )
{
// Define the label string for this user
$label = '' ;
foreach ( $required_fields as $value )
{
if ( $value )
{
$label .= $value . " = " . $ldapuser [ $value ] . " " ;
}
}
$liste [ $key ] = $label ;
}
}
else
{
setEventMessages ( $ldap -> error , $ldap -> errors , 'errors' );
}
}
else
{
setEventMessages ( $ldap -> error , $ldap -> errors , 'errors' );
}
// If user list is full, we show drop-down list
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="' . $_SESSION [ 'newtoken' ] . '">' ;
2019-02-16 10:29:15 +01:00
print '<table class="border centpercent"><tr>' ;
2017-10-07 13:09:31 +02:00
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 ))
{
print $form -> selectarray ( 'users' , $liste , '' , 1 );
print ajax_combobox ( 'users' );
}
2019-02-16 10:29:15 +01:00
print '</td><td class="center">' ;
2017-10-07 13:09:31 +02:00
print '<input type="submit" class="button" value="' . dol_escape_htmltag ( $langs -> trans ( 'Get' )) . '"' . ( count ( $liste ) ? '' : ' disabled' ) . '>' ;
print '</td></tr></table>' ;
print '</form>' ;
print " \n <!-- Form liste LDAP fin --> \n \n " ;
print '<br>' ;
}
print '<form action="' . $_SERVER [ 'PHP_SELF' ] . '" method="POST" name="createuser">' ;
print '<input type="hidden" name="token" value="' . $_SESSION [ 'newtoken' ] . '">' ;
print '<input type="hidden" name="action" value="add">' ;
if ( ! empty ( $ldap_sid )) print '<input type="hidden" name="ldap_sid" value="' . dol_escape_htmltag ( $ldap_sid ) . '">' ;
print '<input type="hidden" name="entity" value="' . $conf -> entity . '">' ;
dol_fiche_head ( '' , '' , '' , 0 , '' );
print dol_set_focus ( '#lastname' );
print '<table class="border centpercent">' ;
// Lastname
print '<tr>' ;
print '<td class="titlefieldcreate"><span class="fieldrequired">' . $langs -> trans ( " Lastname " ) . '</span></td>' ;
print '<td>' ;
if ( ! empty ( $ldap_lastname ))
{
print '<input type="hidden" id="lastname" name="lastname" value="' . $ldap_lastname . '">' ;
print $ldap_lastname ;
}
else
{
print '<input class="minwidth100" type="text" id="lastname" name="lastname" value="' . GETPOST ( 'lastname' ) . '">' ;
}
print '</td></tr>' ;
// Firstname
print '<tr><td>' . $langs -> trans ( " Firstname " ) . '</td>' ;
print '<td>' ;
if ( ! empty ( $ldap_firstname ))
{
print '<input type="hidden" name="firstname" value="' . $ldap_firstname . '">' ;
print $ldap_firstname ;
}
else
{
print '<input class="minwidth100" type="text" name="firstname" value="' . GETPOST ( 'firstname' ) . '">' ;
}
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>' ;
if ( ! empty ( $ldap_login ))
{
print '<input type="hidden" name="login" value="' . $ldap_login . '">' ;
print $ldap_login ;
}
elseif ( ! empty ( $ldap_loginsmb ))
{
print '<input type="hidden" name="login" value="' . $ldap_loginsmb . '">' ;
print $ldap_loginsmb ;
}
else
{
2019-01-27 11:55:16 +01:00
print '<input class="maxwidth200" maxsize="24" type="text" name="login" value="' . dol_escape_htmltag ( GETPOST ( 'login' , 'alpha' )) . '">' ;
2017-10-07 13:09:31 +02:00
}
print '</td></tr>' ;
$generated_password = '' ;
if ( empty ( $ldap_sid )) // ldap_sid is for activedirectory
{
require_once DOL_DOCUMENT_ROOT . '/core/lib/security2.lib.php' ;
$generated_password = getRandomPassword ( false );
}
$password = $generated_password ;
// Password
print '<tr><td class="fieldrequired">' . $langs -> trans ( " Password " ) . '</td>' ;
print '<td>' ;
2018-04-12 15:17:15 +02:00
$valuetoshow = '' ;
2019-01-27 11:55:16 +01:00
if ( preg_match ( '/ldap/' , $dolibarr_main_authentication ))
2017-10-07 13:09:31 +02:00
{
2018-04-12 15:17:15 +02:00
$valuetoshow .= ( $valuetoshow ? ', ' : '' ) . $langs -> trans ( " PasswordOfUserInLDAP " );
2017-10-07 13:09:31 +02:00
}
2019-01-27 11:55:16 +01:00
if ( preg_match ( '/http/' , $dolibarr_main_authentication ))
2018-04-12 15:17:15 +02:00
{
$valuetoshow .= ( $valuetoshow ? ', ' : '' ) . $langs -> trans ( " HTTPBasicPassword " );
}
2019-01-27 11:55:16 +01:00
if ( preg_match ( '/dolibarr/' , $dolibarr_main_authentication ))
2017-10-07 13:09:31 +02:00
{
2018-04-12 15:17:15 +02:00
if ( ! empty ( $ldap_pass )) // For very old system comaptibilty. Now clear password can't be viewed from LDAP read
2017-10-07 13:09:31 +02:00
{
2018-04-12 15:17:15 +02:00
$valuetoshow .= ( $valuetoshow ? ', ' : '' ) . '<input type="hidden" name="password" value="' . $ldap_pass . '">' ; // Dolibarr password is preffiled with LDAP known password
2019-01-27 11:55:16 +01:00
$valuetoshow .= preg_replace ( '/./i' , '*' , $ldap_pass );
2017-10-07 13:09:31 +02:00
}
else
{
// We do not use a field password but a field text to show new password to use.
2018-04-12 15:17:15 +02:00
$valuetoshow .= ( $valuetoshow ? ', ' : '' ) . '<input size="30" maxsize="32" type="text" name="password" value="' . $password . '" autocomplete="new-password">' ;
2017-10-07 13:09:31 +02:00
}
}
2018-04-13 09:05:17 +02:00
2018-04-13 09:39:02 +02:00
// Other form for user password
2018-04-13 09:09:26 +02:00
$parameters = array ( 'valuetoshow' => $valuetoshow , 'password' => $password );
2019-01-27 11:55:16 +01:00
$reshook = $hookmanager -> executeHooks ( 'printUserPasswordField' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
2018-04-13 09:05:17 +02:00
if ( $reshook > 0 ) $valuetoshow = $hookmanager -> resPrint ; // to replace
else $valuetoshow .= $hookmanager -> resPrint ; // to add
2018-04-12 15:17:15 +02:00
print $valuetoshow ;
2017-10-07 13:09:31 +02:00
print '</td></tr>' ;
2018-04-13 09:39:02 +02:00
if ( ! empty ( $conf -> api -> enabled ))
2017-10-07 13:09:31 +02:00
{
// API key
$generated_api_key = '' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/security2.lib.php' ;
$generated_password = getRandomPassword ( false );
print '<tr><td>' . $langs -> trans ( " ApiKey " ) . '</td>' ;
print '<td>' ;
print '<input size="30" maxsize="32" type="text" id="api_key" name="api_key" value="' . $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>' ;
}
else
{
require_once DOL_DOCUMENT_ROOT . '/core/lib/security2.lib.php' ;
// PARTIAL WORKAROUND
$generated_fake_api_key = getRandomPassword ( false );
print '<input type="hidden" name="api_key" value="' . $generated_fake_api_key . '">' ;
}
// Administrator
if ( ! empty ( $user -> admin ))
{
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
2019-02-24 08:21:56 +01:00
if ( ! empty ( $conf -> multicompany -> enabled ) && ! $user -> entity )
2017-10-07 13:09:31 +02:00
{
if ( ! empty ( $conf -> use_javascript_ajax ))
{
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
}
$checked = ( GETPOST ( 'superadmin' , 'int' ) ? ' checked' : '' );
$disabled = ( GETPOST ( 'superadmin' , 'int' ) ? '' : ' disabled' );
print '<input type="checkbox" name="superadmin" value="1"' . $checked . $disabled . ' /> ' . $langs -> trans ( " SuperAdministrator " );
}
print " </td></tr> \n " ;
}
// Type
print '<tr><td>' . $langs -> trans ( " Type " ) . '</td>' ;
print '<td>' ;
2019-01-27 11:55:16 +01:00
print $form -> textwithpicto ( $langs -> trans ( " Internal " ), $langs -> trans ( " InternalExternalDesc " ), 1 , 'help' , '' , 0 , 2 );
2017-10-07 13:09:31 +02:00
print '</td></tr>' ;
2017-12-19 16:16:31 +01:00
// Gender
print '<tr><td>' . $langs -> trans ( " Gender " ) . '</td>' ;
print '<td>' ;
$arraygender = array ( 'man' => $langs -> trans ( " Genderman " ), 'woman' => $langs -> trans ( " Genderwoman " ));
print $form -> selectarray ( 'gender' , $arraygender , GETPOST ( 'gender' ), 1 );
print '</td></tr>' ;
// Employee
$defaultemployee = 1 ;
print '<tr>' ;
print '<td>' . $langs -> trans ( 'Employee' ) . '</td><td>' ;
2019-01-27 11:55:16 +01:00
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>' ;
print $form -> select_dolusers ( $object -> fk_user , 'fk_user' , 1 , array ( $object -> id ), 0 , '' , 0 , $conf -> entity , 0 , 0 , '' , 0 , '' , 'maxwidth300' );
print '</td>' ;
print " </tr> \n " ;
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-01-27 11:55:16 +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-01-27 11:55:16 +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">' ;
2017-10-07 13:09:31 +02:00
print $form -> select_country (( GETPOST ( 'country_id' ) != '' ? GETPOST ( 'country_id' ) : $object -> country_id ));
2019-01-27 11:55:16 +01:00
if ( $user -> admin ) print info_admin ( $langs -> trans ( " YouCanChangeValuesForThisListFromDictionarySetup " ), 1 );
2017-10-07 13:09:31 +02:00
print '</td></tr>' ;
// State
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">' ;
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
print '<tr><td>' . $langs -> trans ( " PhonePro " ) . '</td>' ;
print '<td>' ;
if ( ! empty ( $ldap_phone ))
{
print '<input type="hidden" name="office_phone" value="' . $ldap_phone . '">' ;
print $ldap_phone ;
}
else
{
print '<input size="20" type="text" name="office_phone" value="' . GETPOST ( 'office_phone' ) . '">' ;
}
print '</td></tr>' ;
// Tel portable
print '<tr><td>' . $langs -> trans ( " PhoneMobile " ) . '</td>' ;
print '<td>' ;
if ( ! empty ( $ldap_mobile ))
{
print '<input type="hidden" name="user_mobile" value="' . $ldap_mobile . '">' ;
print $ldap_mobile ;
}
else
{
print '<input size="20" type="text" name="user_mobile" value="' . GETPOST ( 'user_mobile' ) . '">' ;
}
print '</td></tr>' ;
// Fax
print '<tr><td>' . $langs -> trans ( " Fax " ) . '</td>' ;
print '<td>' ;
if ( ! empty ( $ldap_fax ))
{
print '<input type="hidden" name="office_fax" value="' . $ldap_fax . '">' ;
print $ldap_fax ;
}
else
{
print '<input size="20" type="text" name="office_fax" value="' . GETPOST ( 'office_fax' ) . '">' ;
}
print '</td></tr>' ;
2019-09-12 20:03:28 +02:00
if ( ! empty ( $conf -> socialnetworks -> enabled )) {
foreach ( $socialnetworks as $key => $value ) {
2019-09-14 11:26:31 +02:00
if ( ! $value [ 'active' ]) break ;
2019-09-12 20:03:28 +02:00
print '<tr><td>' . $langs -> trans ( $value [ 'label' ]) . '</td>' ;
print '<td>' ;
if ( ! empty ( $ldap_social [ $key ])) {
print '<input type="hidden" name="' . $key . '" value="' . $ldap_social [ $key ] . '">' ;
print $ldap_social [ $key ];
} else {
print '<input class="maxwidth200" type="text" name="' . $key . '" value="' . GETPOST ( $key , 'alphanohtml' ) . '">' ;
}
print '</td></tr>' ;
2017-10-07 13:09:31 +02:00
}
}
2019-09-12 20:03:28 +02:00
// // Skype
// if (! empty($conf->socialnetworks->enabled))
// {
// print '<tr><td>'.$langs->trans("Skype").'</td>';
// print '<td>';
// if (! empty($ldap_skype))
// {
// print '<input type="hidden" name="skype" value="'.$ldap_skype.'">';
// print $ldap_skype;
// }
// else
// {
// print '<input class="maxwidth200" type="text" name="skype" value="'.GETPOST('skype', 'alpha').'">';
// }
// print '</td></tr>';
// }
// // Twitter
// if (! empty($conf->socialnetworks->enabled))
// {
// print '<tr><td>'.$langs->trans("Twitter").'</td>';
// print '<td>';
// if (! empty($ldap_twitter))
// {
// print '<input type="hidden" name="twitter" value="'.$ldap_twitter.'">';
// print $ldap_twitter;
// }
// else
// {
// print '<input class="maxwidth200" type="text" name="twitter" value="'.GETPOST('twitter', 'alpha').'">';
// }
// print '</td></tr>';
// }
// // Facebook
// if (! empty($conf->socialnetworks->enabled))
// {
// print '<tr><td>'.$langs->trans("Facebook").'</td>';
// print '<td>';
// if (! empty($ldap_facebook))
// {
// print '<input type="hidden" name="facebook" value="'.$ldap_facebook.'">';
// print $ldap_facebook;
// }
// else
// {
// print '<input class="maxwidth200" type="text" name="facebook" value="'.GETPOST('facebook', 'alpha').'">';
// }
// print '</td></tr>';
// }
// // LinkedIn
// if (! empty($conf->socialnetworks->enabled))
// {
// print '<tr><td>'.$langs->trans("LinkedIn").'</td>';
// print '<td>';
// if (! empty($ldap_linkedin))
// {
// print '<input type="hidden" name="linkedin" value="'.$ldap_linkedin.'">';
// print $ldap_linkedin;
// }
// else
// {
// print '<input class="maxwidth200" type="text" name="linkedin" value="'.GETPOST('linkedin', 'alpha').'">';
// }
// print '</td></tr>';
// }
2019-02-25 09:07:58 +01:00
2017-10-07 13:09:31 +02:00
// EMail
print '<tr><td' . ( ! empty ( $conf -> global -> USER_MAIL_REQUIRED ) ? ' class="fieldrequired"' : '' ) . '>' . $langs -> trans ( " EMail " ) . '</td>' ;
print '<td>' ;
if ( ! empty ( $ldap_mail ))
{
print '<input type="hidden" name="email" value="' . $ldap_mail . '">' ;
print $ldap_mail ;
}
else
{
print '<input size="40" type="text" name="email" value="' . GETPOST ( 'email' ) . '">' ;
}
print '</td></tr>' ;
// Accountancy code
if ( $conf -> accounting -> enabled )
{
print '<tr><td>' . $langs -> trans ( " AccountancyCode " ) . '</td>' ;
print '<td>' ;
print '<input size="30" type="text" name="accountancy_code" value="' . GETPOST ( 'accountancy_code' ) . '">' ;
print '</td></tr>' ;
}
2014-10-16 06:20:54 +02:00
// User color
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>' ;
2015-09-17 00:47:56 +02:00
print $formother -> selectColor ( GETPOST ( 'color' ) ? GETPOST ( 'color' ) : $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
2017-06-06 07:57:03 +02:00
if ( ! empty ( $conf -> categorie -> enabled ) && ! empty ( $user -> rights -> categorie -> lire ))
2016-02-16 13:54:56 +01:00
{
2018-10-27 17:45:29 +02:00
print '<tr><td>' . $form -> editfieldkey ( 'Categories' , 'usercats' , '' , $object , 0 ) . '</td><td colspan="3">' ;
2017-01-16 10:15:57 +01:00
$cate_arbo = $form -> select_all_categories ( 'user' , null , 'parent' , null , null , 1 );
2019-02-12 19:00:50 +01:00
print $form -> multiselectarray ( 'usercats' , $cate_arbo , GETPOST ( 'usercats' , 'array' ), null , null , null , null , '90%' );
2016-02-13 10:42:45 +01:00
print " </td></tr> " ;
}
2017-08-25 15:04:55 +02:00
2017-08-25 13:25:34 +02:00
// Multicompany
2018-07-05 22:15:55 +02:00
if ( ! empty ( $conf -> multicompany -> enabled ) && is_object ( $mc ))
{
// This is now done with hook formObjectOptions. Keep this code for backward compatibility with old multicompany module
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>' ;
print " <td> " . $mc -> select_entities ( $conf -> entity );
print " </td></tr> \n " ;
}
else
{
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
$parameters = array ( 'objectsrc' => $objectsrc , 'colspan' => ' colspan="3"' );
2019-01-27 11:55:16 +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 ;
2018-04-13 13:28:48 +02:00
if ( empty ( $reshook ))
2017-10-07 13:09:31 +02:00
{
2019-01-27 11:55:16 +01:00
print $object -> showOptionals ( $extrafields , 'edit' );
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' ;
2019-01-27 11:55:16 +01:00
$doleditor = new DolEditor ( 'note' , '' , '' , 120 , 'dolibarr_notes' , '' , false , true , $conf -> global -> 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>' ;
print '<td>' ;
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php' ;
2019-01-27 11:55:16 +01:00
$doleditor = new DolEditor ( 'signature' , GETPOST ( 'signature' ), '' , 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)
// Position/Job
print '<tr><td class="titlefieldcreate">' . $langs -> trans ( " PostOrFunction " ) . '</td>' ;
print '<td>' ;
print '<input class="maxwidth200" type="text" name="job" value="' . GETPOST ( 'job' ) . '">' ;
print '</td></tr>' ;
2019-02-15 05:24:25 +01:00
// Default warehouse
2019-02-15 17:12:39 +01:00
if ( ! empty ( $conf -> stock -> enabled ))
{
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
if (( ! empty ( $conf -> salaries -> enabled ) && ! empty ( $user -> rights -> salaries -> read ))
|| ( ! empty ( $conf -> hrm -> enabled ) && ! empty ( $user -> rights -> hrm -> employee -> read )))
{
$langs -> load ( " salaries " );
// THM
print '<tr><td>' ;
$text = $langs -> trans ( " THM " );
print $form -> textwithpicto ( $text , $langs -> trans ( " THMDescription " ), 1 , 'help' , 'classthm' );
print '</td>' ;
print '<td>' ;
print '<input size="8" type="text" name="thm" value="' . GETPOST ( 'thm' ) . '">' ;
print '</td>' ;
print " </tr> \n " ;
// TJM
print '<tr><td>' ;
$text = $langs -> trans ( " TJM " );
print $form -> textwithpicto ( $text , $langs -> trans ( " TJMDescription " ), 1 , 'help' , 'classtjm' );
print '</td>' ;
print '<td>' ;
print '<input size="8" type="text" name="tjm" value="' . GETPOST ( 'tjm' ) . '">' ;
print '</td>' ;
print " </tr> \n " ;
// Salary
print '<tr><td>' . $langs -> trans ( " Salary " ) . '</td>' ;
print '<td>' ;
print '<input size="8" type="text" name="salary" value="' . GETPOST ( 'salary' ) . '">' ;
print '</td>' ;
print " </tr> \n " ;
}
// Weeklyhours
print '<tr><td>' . $langs -> trans ( " WeeklyHours " ) . '</td>' ;
print '<td>' ;
print '<input size="8" type="text" name="weeklyhours" value="' . GETPOST ( 'weeklyhours' ) . '">' ;
print '</td>' ;
print " </tr> \n " ;
// Date employment
print '<tr><td>' . $langs -> trans ( " DateEmployment " ) . '</td>' ;
print '<td>' ;
2018-09-09 08:02:26 +02:00
print $form -> selectDate ( GETPOST ( 'dateemployment' ), 'dateemployment' , 0 , 0 , 1 , 'formdateemployment' , 1 , 0 );
2017-12-19 16:16:31 +01:00
print '</td>' ;
print " </tr> \n " ;
2018-05-12 18:05:06 +02:00
// Date employment END
print '<tr><td>' . $langs -> trans ( " DateEmploymentEnd " ) . '</td>' ;
print '<td>' ;
2018-09-09 08:02:26 +02:00
print $form -> selectDate ( GETPOST ( 'dateemploymentend' ), 'dateemploymentend' , 0 , 0 , 1 , 'formdateemploymentend' , 1 , 0 );
2018-05-12 18:05:06 +02:00
print '</td>' ;
print " </tr> \n " ;
2017-12-19 16:16:31 +01:00
// Date birth
print '<tr><td>' . $langs -> trans ( " DateToBirth " ) . '</td>' ;
print '<td>' ;
2018-09-09 08:02:26 +02:00
print $form -> selectDate ( GETPOST ( 'birth' ), 'birth' , 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
2015-05-04 11:41:30 +02:00
dol_fiche_end ();
2019-02-16 10:29:15 +01:00
print '<div class="center">' ;
2017-10-07 13:09:31 +02:00
print '<input class="button" value="' . $langs -> trans ( " CreateUser " ) . '" name="create" type="submit">' ;
//print ' ';
//print '<input value="'.$langs->trans("Cancel").'" class="button" type="submit" name="cancel">';
print '</div>' ;
2011-11-02 14:14:46 +01:00
2017-10-07 13:09:31 +02:00
print " </form> " ;
2002-12-13 17:51:03 +01:00
}
else
{
2017-10-07 13:09:31 +02:00
/* ************************************************************************** */
/* */
/* View and edition */
/* */
/* ************************************************************************** */
if ( $id > 0 )
{
$object -> fetch ( $id , '' , '' , 1 );
2019-01-27 11:55:16 +01:00
if ( $res < 0 ) { dol_print_error ( $db , $object -> error ); exit ; }
2018-02-21 14:48:25 +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
2018-07-04 14:48:00 +02:00
if ( empty ( $conf -> global -> MULTICOMPANY_TRANSVERSE_MODE ))
{
$object -> getrights ();
2018-12-18 21:55:14 +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
if ( ! empty ( $conf -> ldap -> enabled ) && ! empty ( $object -> ldap_sid ))
{
$ldap = new Ldap ();
$result = $ldap -> connect_bind ();
if ( $result > 0 )
{
$userSearchFilter = '(' . $conf -> global -> LDAP_FILTER_CONNECTION . '(' . $ldap -> getUserIdentifier () . '=' . $object -> login . '))' ;
2019-01-27 11:55:16 +01:00
$entries = $ldap -> fetch ( $object -> login , $userSearchFilter );
2017-10-07 13:09:31 +02:00
if ( ! $entries )
{
setEventMessages ( $ldap -> error , $ldap -> errors , 'errors' );
}
$passDoNotExpire = 0 ;
$userChangePassNextLogon = 0 ;
$userDisabled = 0 ;
$statutUACF = '' ;
// Check options of user account
if ( count ( $ldap -> uacf ) > 0 )
{
foreach ( $ldap -> uacf as $key => $statut )
{
if ( $key == 65536 )
{
$passDoNotExpire = 1 ;
$statutUACF = $statut ;
}
}
}
else
{
$userDisabled = 1 ;
$statutUACF = " ACCOUNTDISABLE " ;
}
if ( $ldap -> pwdlastset == 0 )
{
$userChangePassNextLogon = 1 ;
}
}
}
2011-06-29 12:23:32 +02:00
2017-10-07 13:09:31 +02:00
// Show tabs
2015-11-17 21:22:45 +01:00
if ( $mode == 'employee' ) // For HRM module development
{
$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>' ;
2015-11-17 21:22:45 +01:00
}
else
{
$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
/*
2011-06-29 12:23:32 +02:00
* Confirmation reinitialisation mot de passe
*/
2017-10-07 13:09:31 +02:00
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
/*
2011-06-29 12:23:32 +02:00
* Confirmation envoi mot de passe
*/
2017-10-07 13:09:31 +02:00
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
/*
2014-10-16 06:20:54 +02:00
* Confirm deactivation
2011-06-29 12:23:32 +02:00
*/
2017-10-07 13:09:31 +02:00
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
/*
2014-10-16 06:20:54 +02:00
* Confirm activation
2011-06-29 12:23:32 +02:00
*/
2017-10-07 13:09:31 +02:00
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
/*
2011-06-29 12:23:32 +02:00
* Confirmation suppression
*/
2017-10-07 13:09:31 +02:00
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
/*
2011-06-29 12:23:32 +02:00
* Fiche en mode visu
*/
2017-10-07 13:09:31 +02:00
if ( $action != 'edit' )
{
2017-05-19 13:39:00 +02:00
dol_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
print '<tr><td class="titlefield">' . $langs -> trans ( " Login " ) . '</td>' ;
if ( ! empty ( $object -> ldap_sid ) && $object -> statut == 0 )
{
print '<td class="error">' . $langs -> trans ( " LoginAccountDisableInDolibarr " ) . '</td>' ;
}
else
{
print '<td>' . $object -> login . '</td>' ;
}
print '</tr>' . " \n " ;
2008-08-28 14:08:02 +02:00
2017-10-07 13:09:31 +02:00
// Password
print '<tr><td>' . $langs -> trans ( " Password " ) . '</td>' ;
2018-04-12 15:17:15 +02:00
2018-10-16 21:58:33 +02:00
print '<td class="wordbreak">' ;
2018-04-12 15:17:15 +02:00
$valuetoshow = '' ;
2019-01-27 11:55:16 +01:00
if ( preg_match ( '/ldap/' , $dolibarr_main_authentication ))
2017-10-07 13:09:31 +02:00
{
2018-04-12 15:17:15 +02:00
if ( ! empty ( $object -> ldap_sid ))
2017-10-07 13:09:31 +02:00
{
2018-04-12 15:17:15 +02:00
if ( $passDoNotExpire )
{
$valuetoshow .= ( $valuetoshow ? ( ' ' . $langs -> trans ( " or " ) . ' ' ) : '' ) . $langs -> trans ( " LdapUacf_ " . $statutUACF );
}
2019-01-27 10:49:34 +01:00
elseif ( $userChangePassNextLogon )
2018-04-12 15:17:15 +02:00
{
2019-01-27 11:55:16 +01:00
$valuetoshow .= ( $valuetoshow ? ( ' ' . $langs -> trans ( " or " ) . ' ' ) : '' ) . '<span class="warning">' . $langs -> trans ( " UserMustChangePassNextLogon " , $ldap -> domainFQDN ) . '</span>' ;
2018-04-12 15:17:15 +02:00
}
2019-01-27 10:49:34 +01:00
elseif ( $userDisabled )
2018-04-12 15:17:15 +02:00
{
2019-01-27 11:55:16 +01:00
$valuetoshow .= ( $valuetoshow ? ( ' ' . $langs -> trans ( " or " ) . ' ' ) : '' ) . '<span class="warning">' . $langs -> trans ( " LdapUacf_ " . $statutUACF , $ldap -> domainFQDN ) . '</span>' ;
2018-04-12 15:17:15 +02:00
}
else
{
$valuetoshow .= ( $valuetoshow ? ( ' ' . $langs -> trans ( " or " ) . ' ' ) : '' ) . $langs -> trans ( " PasswordOfUserInLDAP " );
}
2017-10-07 13:09:31 +02:00
}
else
{
2018-04-12 15:17:15 +02:00
$valuetoshow .= ( $valuetoshow ? ( ' ' . $langs -> trans ( " or " ) . ' ' ) : '' ) . $langs -> trans ( " PasswordOfUserInLDAP " );
2017-10-07 13:09:31 +02:00
}
}
2019-01-27 11:55:16 +01:00
if ( preg_match ( '/http/' , $dolibarr_main_authentication ))
2017-10-07 13:09:31 +02:00
{
2018-04-12 15:17:15 +02:00
$valuetoshow .= ( $valuetoshow ? ( ' ' . $langs -> trans ( " or " ) . ' ' ) : '' ) . $langs -> trans ( " HTTPBasicPassword " );
}
2019-01-27 11:55:16 +01:00
if ( preg_match ( '/dolibarr/' , $dolibarr_main_authentication ))
2018-04-12 15:17:15 +02:00
{
2019-01-27 11:55:16 +01:00
if ( $object -> pass ) $valuetoshow .= ( $valuetoshow ? ( ' ' . $langs -> trans ( " or " ) . ' ' ) : '' ) . preg_replace ( '/./i' , '*' , $object -> pass );
2017-10-07 13:09:31 +02:00
else
{
2018-04-12 15:17:15 +02:00
if ( $user -> admin ) $valuetoshow .= ( $valuetoshow ? ( ' ' . $langs -> trans ( " or " ) . ' ' ) : '' ) . $langs -> trans ( " Crypted " ) . ': ' . $object -> pass_indatabase_crypted ;
else $valuetoshow .= ( $valuetoshow ? ( ' ' . $langs -> trans ( " or " ) . ' ' ) : '' ) . $langs -> trans ( " Hidden " );
2017-10-07 13:09:31 +02:00
}
}
2018-04-13 09:05:17 +02:00
2018-04-13 09:39:02 +02:00
// Other form for user password
2018-04-13 09:05:17 +02:00
$parameters = array ( 'valuetoshow' => $valuetoshow );
2019-01-27 11:55:16 +01:00
$reshook = $hookmanager -> executeHooks ( 'printUserPasswordField' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
2018-04-13 09:05:17 +02:00
if ( $reshook > 0 ) $valuetoshow = $hookmanager -> resPrint ; // to replace
else $valuetoshow .= $hookmanager -> resPrint ; // to add
2018-04-12 15:17:15 +02:00
print $valuetoshow ;
print " </td> " ;
2017-10-07 13:09:31 +02:00
print '</tr>' . " \n " ;
// API key
2017-12-19 16:16:31 +01:00
if ( ! empty ( $conf -> api -> enabled ) && $user -> admin ) {
2017-10-07 13:09:31 +02:00
print '<tr><td>' . $langs -> trans ( " ApiKey " ) . '</td>' ;
print '<td>' ;
2019-01-27 11:55:16 +01:00
if ( ! empty ( $object -> api_key )) print preg_replace ( '/./' , '*' , $object -> api_key );
2017-10-07 13:09:31 +02:00
print '</td></tr>' ;
}
// Administrator
print '<tr><td>' . $langs -> trans ( " Administrator " ) . '</td><td>' ;
if ( ! empty ( $conf -> multicompany -> enabled ) && $object -> admin && ! $object -> entity )
{
2019-01-27 11:55:16 +01:00
print $form -> textwithpicto ( yn ( $object -> admin ), $langs -> trans ( " SuperAdministratorDesc " ), 1 , " superadmin " );
2017-10-07 13:09:31 +02:00
}
2019-01-27 10:49:34 +01:00
elseif ( $object -> admin )
2017-10-07 13:09:31 +02:00
{
2019-01-27 11:55:16 +01:00
print $form -> textwithpicto ( yn ( $object -> admin ), $langs -> trans ( " AdministratorDesc " ), 1 , " admin " );
2017-10-07 13:09:31 +02:00
}
else
{
print yn ( $object -> admin );
}
print '</td></tr>' . " \n " ;
// Type
print '<tr><td>' ;
$text = $langs -> trans ( " Type " );
print $form -> textwithpicto ( $text , $langs -> trans ( " InternalExternalDesc " ));
print '</td><td>' ;
$type = $langs -> trans ( " Internal " );
if ( $object -> societe_id > 0 ) $type = $langs -> trans ( " External " );
2015-06-20 19:42:07 +02:00
print $type ;
2017-10-07 13:09:31 +02:00
if ( $object -> ldap_sid ) print ' (' . $langs -> trans ( " DomainUser " ) . ')' ;
print '</td></tr>' . " \n " ;
2008-08-28 14:08:02 +02:00
2017-10-07 13:09:31 +02:00
// Ldap sid
if ( $object -> ldap_sid )
{
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
// Gender
print '<tr><td>' . $langs -> trans ( " Gender " ) . '</td>' ;
print '<td>' ;
if ( $object -> gender ) print $langs -> trans ( " Gender " . $object -> gender );
print '</td></tr>' ;
// Employee
print '<tr><td>' . $langs -> trans ( " Employee " ) . '</td><td colspan="2">' ;
print yn ( $object -> employee );
print '</td></tr>' . " \n " ;
2017-06-06 07:57:03 +02:00
2017-10-07 13:09:31 +02:00
// TODO Move this into tab RH, visible when salarie or RH is visible (HierarchicalResponsible must be on both tab)
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>' ;
if ( empty ( $object -> fk_user )) print $langs -> trans ( " None " );
else {
$huser = new User ( $db );
$huser -> fetch ( $object -> fk_user );
print $huser -> getNomUrl ( 1 );
}
print '</td>' ;
print " </tr> \n " ;
2013-09-18 21:22:24 +02:00
2017-12-19 16:16:31 +01:00
// Position/Job
print '<tr><td>' . $langs -> trans ( " PostOrFunction " ) . '</td>' ;
print '<td>' . $object -> job . '</td>' ;
print '</tr>' . " \n " ;
2019-02-27 13:48:13 +01:00
2019-02-15 05:24:25 +01:00
// Default warehouse
2019-02-15 17:12:39 +01:00
if ( ! empty ( $conf -> stock -> enabled ))
{
require_once DOL_DOCUMENT_ROOT . '/product/stock/class/entrepot.class.php' ;
$warehousestatic = new Entrepot ( $db );
$warehousestatic -> fetch ( $object -> fk_warehouse );
print '<tr><td>' . $langs -> trans ( " DefaultWarehouse " ) . '</td><td>' ;
print $warehousestatic -> getNomUrl ();
print '</td></tr>' ;
}
2017-12-19 16:16:31 +01:00
2017-10-13 17:44:31 +02:00
//$childids = $user->getAllChildIds(1);
2017-10-07 13:09:31 +02:00
if (( ! empty ( $conf -> salaries -> enabled ) && ! empty ( $user -> rights -> salaries -> read ))
|| ( ! empty ( $conf -> hrm -> enabled ) && ! empty ( $user -> rights -> hrm -> employee -> read )))
{
2017-10-13 17:44:31 +02:00
// Even a superior can't see this info of its subordinates wihtout $user->rights->salaries->read and $user->rights->hrm->employee->read (setting/viewing is reserverd to HR people).
// However, he can see the valuation of timesheet of its subordinates even without these permissions.
2017-10-07 13:09:31 +02:00
$langs -> load ( " salaries " );
// THM
print '<tr><td>' ;
$text = $langs -> trans ( " THM " );
print $form -> textwithpicto ( $text , $langs -> trans ( " THMDescription " ), 1 , 'help' , 'classthm' );
print '</td>' ;
print '<td>' ;
2019-01-27 11:55:16 +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>' ;
$text = $langs -> trans ( " TJM " );
print $form -> textwithpicto ( $text , $langs -> trans ( " TJMDescription " ), 1 , 'help' , 'classtjm' );
print '</td>' ;
print '<td>' ;
2019-01-27 11:55:16 +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 " ;
// Salary
print '<tr><td>' . $langs -> trans ( " Salary " ) . '</td>' ;
print '<td>' ;
2019-01-27 11:55:16 +01:00
print ( $object -> salary != '' ? price ( $object -> salary , '' , $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
// Weeklyhours
print '<tr><td>' . $langs -> trans ( " WeeklyHours " ) . '</td>' ;
print '<td>' ;
2014-09-13 17:41:26 +02:00
print price2num ( $object -> weeklyhours );
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
print '<tr><td>' . $langs -> trans ( " DateEmployment " ) . '</td>' ;
print '<td>' ;
2018-08-20 17:14:03 +02:00
print dol_print_date ( $object -> dateemployment , 'day' );
2017-10-07 13:09:31 +02:00
print '</td>' ;
print " </tr> \n " ;
2016-09-27 15:16:16 +02:00
2018-05-12 18:05:06 +02:00
// Date employment
print '<tr><td>' . $langs -> trans ( " DateEmploymentEnd " ) . '</td>' ;
print '<td>' ;
print dol_print_date ( $object -> dateemploymentend );
print '</td>' ;
print " </tr> \n " ;
2017-12-19 16:16:31 +01:00
// Date of birth
print '<tr><td>' . $langs -> trans ( " DateToBirth " ) . '</td>' ;
print '<td>' ;
print dol_print_date ( $object -> birth , 'day' );
print '</td>' ;
print " </tr> \n " ;
// Accountancy code
if ( $conf -> accounting -> enabled )
{
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>' ;
print '<div class="fichehalfright"><div class="ficheaddleft">' ;
2015-10-15 16:11:03 +02:00
2017-10-07 13:09:31 +02:00
print '<div class="underbanner clearboth"></div>' ;
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
if ( ! empty ( $conf -> agenda -> enabled ))
{
print '<tr><td>' . $langs -> trans ( " ColorUser " ) . '</td>' ;
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
if ( ! empty ( $conf -> categorie -> enabled ) && ! empty ( $user -> rights -> categorie -> lire ))
{
2019-02-10 10:45:49 +01:00
print '<tr><td>' . $langs -> trans ( " Categories " ) . '</td>' ;
2016-02-16 13:54:56 +01:00
print '<td colspan="3">' ;
2019-02-10 10:45:49 +01:00
print $form -> showCategories ( $object -> id , '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
2019-01-27 11:55:16 +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
2017-10-07 13:09:31 +02:00
print '<tr><td class="titlefield">' . $langs -> trans ( " LastConnexion " ) . '</td>' ;
2019-01-27 11:55:16 +01:00
print '<td>' . dol_print_date ( $object -> datelastlogin , " dayhour " ) . '</td>' ;
2017-10-07 13:09:31 +02:00
print " </tr> \n " ;
2017-06-06 07:57:03 +02:00
2017-10-07 13:09:31 +02:00
print '<tr><td>' . $langs -> trans ( " PreviousConnexion " ) . '</td>' ;
2019-01-27 11:55:16 +01:00
print '<td>' . dol_print_date ( $object -> datepreviouslogin , " dayhour " ) . '</td>' ;
2017-10-07 13:09:31 +02:00
print " </tr> \n " ;
2017-06-06 07:57:03 +02:00
2018-07-05 22:15:55 +02:00
// Multicompany
if ( ! empty ( $conf -> multicompany -> enabled ) && is_object ( $mc ))
{
// This is now done with hook formObjectOptions. Keep this code for backward compatibility with old multicompany module
if ( ! method_exists ( $mc , 'formObjectOptions' ))
{
2019-02-03 14:29:45 +01:00
if ( ! empty ( $conf -> multicompany -> enabled ) && empty ( $conf -> global -> MULTICOMPANY_TRANSVERSE_MODE ) && $conf -> entity == 1 && $user -> admin && ! $user -> entity )
{
2018-07-05 22:15:55 +02:00
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 " ;
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
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
if ( ! empty ( $conf -> societe -> enabled ))
{
print '<tr><td>' . $langs -> trans ( " LinkToCompanyContact " ) . '</td>' ;
print '<td>' ;
if ( isset ( $object -> socid ) && $object -> socid > 0 )
{
$societe = new Societe ( $db );
$societe -> fetch ( $object -> socid );
2019-01-27 11:55:16 +01:00
print $societe -> getNomUrl ( 1 , '' );
2017-10-07 13:09:31 +02:00
}
else
{
print $langs -> trans ( " ThisUserIsNot " );
}
if ( ! empty ( $object -> contactid ))
{
$contact = new Contact ( $db );
$contact -> fetch ( $object -> contactid );
if ( $object -> socid > 0 ) print ' / ' ;
else print '<br>' ;
2019-01-27 11:55:16 +01:00
print '<a href="' . DOL_URL_ROOT . '/contact/card.php?id=' . $object -> contactid . '">' . img_object ( $langs -> trans ( " ShowContact " ), 'contact' ) . ' ' . dol_trunc ( $contact -> getFullName ( $langs ), 32 ) . '</a>' ;
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
if ( ! empty ( $conf -> adherent -> enabled ))
{
$langs -> load ( " members " );
print '<tr><td>' . $langs -> trans ( " LinkedToDolibarrMember " ) . '</td>' ;
print '<td>' ;
if ( $object -> fk_member )
{
$adh = new Adherent ( $db );
$adh -> fetch ( $object -> fk_member );
$adh -> ref = $adh -> getFullname ( $langs ); // Force to show login instead of id
print $adh -> getNomUrl ( 1 );
}
else
{
print $langs -> trans ( " UserNotLinkedToMember " );
}
print '</td>' ;
print '</tr>' . " \n " ;
}
2011-06-29 12:23:32 +02:00
2017-10-07 13:09:31 +02:00
// Signature
print '<tr><td class="tdtop">' . $langs -> trans ( 'Signature' ) . '</td><td>' ;
print dol_htmlentitiesbr ( $object -> signature );
print " </td></tr> \n " ;
2017-05-19 12:58:38 +02:00
2017-10-07 13:09:31 +02:00
print " </table> \n " ;
2015-10-11 15:21:21 +02:00
print '</div>' ;
2015-10-15 16:11:03 +02:00
2017-10-07 13:09:31 +02:00
print '</div></div>' ;
print '<div style="clear:both"></div>' ;
2015-10-15 16:11:03 +02:00
2011-06-29 12:23:32 +02:00
2017-10-07 13:09:31 +02:00
dol_fiche_end ();
2011-06-29 12:23:32 +02:00
2017-10-07 13:09:31 +02:00
/*
2012-03-20 17:03:10 +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
2018-06-15 16:05:50 +02:00
$parameters = array ();
2019-01-27 11:55:16 +01:00
$reshook = $hookmanager -> executeHooks ( 'addMoreActionsButtons' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
2018-06-15 16:05:50 +02:00
if ( empty ( $reshook ))
2017-10-07 13:09:31 +02:00
{
2018-06-15 16:05:50 +02:00
if ( ! empty ( $object -> email ))
2017-10-07 13:09:31 +02:00
{
2018-06-15 16:05:50 +02:00
$langs -> load ( " mails " );
2019-06-21 11:20:04 +02:00
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>' ;
2017-10-07 13:09:31 +02:00
}
else
{
2018-06-15 16:05:50 +02:00
$langs -> load ( " mails " );
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 ( " NoEMail " )) . '">' . $langs -> trans ( 'SendMail' ) . '</a></div>' ;
2017-10-07 13:09:31 +02:00
}
2011-06-29 12:23:32 +02:00
2018-06-15 16:05:50 +02:00
if ( $caneditfield && ( empty ( $conf -> multicompany -> enabled ) || ! $user -> entity || ( $object -> entity == $conf -> entity ) || ( $conf -> global -> MULTICOMPANY_TRANSVERSE_MODE && $conf -> entity == 1 )))
2012-03-20 17:03:10 +01:00
{
2018-06-15 16:05:50 +02: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>' ;
2018-06-15 16:05:50 +02:00
}
else
{
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER [ 'PHP_SELF' ] . '?id=' . $object -> id . '&action=edit">' . $langs -> trans ( " Modify " ) . '</a></div>' ;
}
2017-10-07 13:09:31 +02:00
}
2018-06-15 16:05:50 +02:00
elseif ( $caneditpassword && ! $object -> ldap_sid &&
( empty ( $conf -> multicompany -> enabled ) || ! $user -> entity || ( $object -> entity == $conf -> entity ) || ( $conf -> global -> MULTICOMPANY_TRANSVERSE_MODE && $conf -> entity == 1 )))
2017-10-07 13:09:31 +02:00
{
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=edit">' . $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
if ( $conf -> global -> USER_PASSWORD_GENERATED != 'none' )
2012-03-20 17:03:10 +01:00
{
2018-06-15 16:05:50 +02: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 ( " ReinitPassword " ) . '</a></div>' ;
2018-06-15 16:05:50 +02:00
}
elseif (( $user -> id != $id && $caneditpassword ) && $object -> login && ! $object -> ldap_sid &&
(( empty ( $conf -> multicompany -> enabled ) && $object -> entity == $user -> entity ) || ! $user -> entity || ( $object -> entity == $conf -> entity ) || ( $conf -> global -> MULTICOMPANY_TRANSVERSE_MODE && $conf -> entity == 1 )))
{
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER [ 'PHP_SELF' ] . '?id=' . $object -> id . '&action=password">' . $langs -> trans ( " ReinitPassword " ) . '</a></div>' ;
}
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>' ;
2018-06-15 16:05:50 +02:00
}
2019-01-27 10:49:34 +01:00
elseif (( $user -> id != $id && $caneditpassword ) && $object -> login && ! $object -> ldap_sid &&
2018-06-15 16:05:50 +02: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>' ;
2018-11-13 21:40:17 +01:00
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 &&
2017-10-07 13:09:31 +02: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=enable">' . $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 &&
(( empty ( $conf -> multicompany -> enabled ) && $object -> entity == $user -> entity ) || ! $user -> entity || ( $object -> entity == $conf -> entity ) || ( $conf -> global -> MULTICOMPANY_TRANSVERSE_MODE && $conf -> entity == 1 )))
2017-10-07 13:09:31 +02:00
{
2018-06-15 16:05:50 +02:00
print '<div class="inline-block divButAction"><a class="butActionDelete" href="' . $_SERVER [ 'PHP_SELF' ] . '?action=disable&id=' . $object -> id . '">' . $langs -> trans ( " DisableUser " ) . '</a></div>' ;
2017-10-07 13:09:31 +02:00
}
2019-02-27 13:48:13 +01:00
else
{
if ( $user -> id == $id )
{
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="' . $langs -> trans ( " CantDisableYourself " ) . '">' . $langs -> trans ( " DisableUser " ) . '</a></div>' ;
}
}
2018-06-15 16:05:50 +02:00
// Delete
if ( $user -> id <> $id && $candisableuser &&
(( empty ( $conf -> multicompany -> enabled ) && $object -> entity == $user -> entity ) || ! $user -> entity || ( $object -> entity == $conf -> entity ) || ( $conf -> global -> MULTICOMPANY_TRANSVERSE_MODE && $conf -> entity == 1 )))
2017-10-07 13:09:31 +02:00
{
2018-06-15 16:05:50 +02:00
if ( $user -> admin || ! $object -> admin ) // If user edited is admin, delete is possible on for an admin
{
print '<div class="inline-block divButAction"><a class="butActionDelete" href="' . $_SERVER [ 'PHP_SELF' ] . '?action=delete&id=' . $object -> id . '">' . $langs -> trans ( " DeleteUser " ) . '</a></div>' ;
}
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
2017-10-08 16:34:42 +02:00
if ( GETPOST ( 'modelselected' )) $action = 'presend' ;
// Presend form
$modelmail = 'user' ;
$defaulttopic = 'Information' ;
$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' ;
2017-11-04 15:40:35 +01:00
if ( $action != 'presend' && $action != 'send' )
2017-10-07 13:09:31 +02:00
{
/*
2017-05-19 12:58:38 +02:00
* List of groups of user
*/
2017-06-06 07:57:03 +02:00
2017-10-07 13:09:31 +02:00
if ( $canreadgroup )
{
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 ();
$usergroup = new UserGroup ( $db );
$groupslist = $usergroup -> listGroupsForUser ( $object -> id );
if ( ! empty ( $groupslist ))
{
2017-11-04 15:40:35 +01:00
foreach ( $groupslist as $groupforuser )
2017-10-07 13:09:31 +02:00
{
2017-11-04 15:40:35 +01:00
$exclude [] = $groupforuser -> id ;
2017-10-07 13:09:31 +02:00
}
}
if ( $caneditgroup )
{
print '<form action="' . $_SERVER [ 'PHP_SELF' ] . '?id=' . $id . '" method="POST">' . " \n " ;
print '<input type="hidden" name="token" value="' . $_SESSION [ 'newtoken' ] . '" />' ;
print '<input type="hidden" name="action" value="addgroup" />' ;
}
print '<table class="noborder" width="100%">' . " \n " ;
2017-11-04 15:40:35 +01:00
// Other form for add user to group
$parameters = array ( 'caneditgroup' => $caneditgroup , 'groupslist' => $groupslist , 'exclude' => $exclude );
2019-01-27 11:55:16 +01:00
$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 ;
if ( empty ( $reshook ))
2017-10-07 13:09:31 +02:00
{
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">' ;
2017-11-04 15:40:35 +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 . '" />' ;
print '<input type="submit" class="button" value="' . $langs -> trans ( " Add " ) . '" />' ;
}
print '</th></tr>' . " \n " ;
/*
* Groups assigned to user
*/
if ( ! empty ( $groupslist ))
{
foreach ( $groupslist as $group )
2017-10-07 13:09:31 +02:00
{
2017-11-04 15:40:35 +01:00
print '<tr class="oddeven">' ;
print '<td>' ;
if ( $caneditgroup )
2017-10-07 13:09:31 +02:00
{
2019-01-27 11:55:16 +01:00
print '<a href="' . DOL_URL_ROOT . '/user/group/card.php?id=' . $group -> id . '">' . img_object ( $langs -> trans ( " ShowGroup " ), " group " ) . ' ' . $group -> name . '</a>' ;
2017-10-07 13:09:31 +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">' ;
2017-11-04 15:40:35 +01:00
if ( $caneditgroup )
2017-10-07 13:09:31 +02:00
{
2017-11-04 15:40:35 +01:00
print '<a href="' . $_SERVER [ 'PHP_SELF' ] . '?id=' . $object -> id . '&action=removegroup&group=' . $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>' ;
2017-10-07 13:09:31 +02:00
}
2017-11-04 15:40:35 +01:00
else
{
print " " ;
}
print " </td></tr> \n " ;
2017-10-07 13:09:31 +02:00
}
}
2017-11-04 15:40:35 +01: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-10-07 13:09:31 +02:00
}
2017-06-06 07:57:03 +02:00
2017-10-07 13:09:31 +02:00
print " </table> " ;
if ( $caneditgroup )
{
print '</form>' ;
}
print " <br> " ;
}
}
}
/*
2017-05-19 12:58:38 +02:00
* Fiche en mode edition
*/
2017-10-07 13:09:31 +02:00
if ( $action == 'edit' && ( $canedituser || $caneditfield || $caneditpassword || ( $user -> id == $object -> id )))
{
print '<form action="' . $_SERVER [ 'PHP_SELF' ] . '?id=' . $object -> id . '" method="POST" name="updateuser" enctype="multipart/form-data">' ;
print '<input type="hidden" name="token" value="' . $_SESSION [ 'newtoken' ] . '">' ;
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
2017-10-07 13:09:31 +02:00
dol_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
2017-05-19 12:58:38 +02:00
if ( ! empty ( $conf -> global -> MAIN_SHOW_TECHNICAL_ID ))
{
2017-12-19 16:16:31 +01:00
print '<tr><td class="titlefield">' . $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
}
2017-10-07 13:09:31 +02:00
// Lastname
print " <tr> " ;
2017-12-19 16:16:31 +01:00
print '<td class="titlefield fieldrequired">' . $langs -> trans ( " Lastname " ) . '</td>' ;
2017-10-07 13:09:31 +02:00
print '<td>' ;
if ( $caneditfield && ! $object -> ldap_sid )
{
print '<input class="minwidth100" type="text" class="flat" name="lastname" value="' . $object -> lastname . '">' ;
}
else
{
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>' ;
if ( $caneditfield && ! $object -> ldap_sid )
2017-05-19 12:58:38 +02:00
{
2017-10-07 13:09:31 +02:00
print '<input class="minwidth100" type="text" class="flat" name="firstname" value="' . $object -> firstname . '">' ;
}
else
{
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>' ;
if ( $user -> admin && ! $object -> ldap_sid )
{
print '<input size="12" maxlength="24" type="text" class="flat" name="login" value="' . $object -> login . '">' ;
}
else
{
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
// Pass
print '<tr><td>' . $langs -> trans ( " Password " ) . '</td>' ;
print '<td>' ;
2018-04-12 15:17:15 +02:00
$valuetoshow = '' ;
2019-01-27 11:55:16 +01:00
if ( preg_match ( '/ldap/' , $dolibarr_main_authentication ))
2017-10-07 13:09:31 +02:00
{
2018-04-12 15:17:15 +02:00
$valuetoshow .= ( $valuetoshow ? ( ' ' . $langs -> trans ( " or " ) . ' ' ) : '' ) . $langs -> trans ( " PasswordOfUserInLDAP " );
2017-10-07 13:09:31 +02:00
}
2019-01-27 11:55:16 +01:00
if ( preg_match ( '/http/' , $dolibarr_main_authentication ))
2017-10-07 13:09:31 +02:00
{
2019-01-27 11:55:16 +01:00
$valuetoshow .= ( $valuetoshow ? ( ' ' . $langs -> trans ( " or " ) . ' ' ) : '' ) . $form -> textwithpicto ( $text , $langs -> trans ( " DolibarrInHttpAuthenticationSoPasswordUseless " , $dolibarr_main_authentication ), 1 , 'warning' );
2017-10-07 13:09:31 +02:00
}
2019-01-27 11:55:16 +01:00
if ( preg_match ( '/dolibarr/' , $dolibarr_main_authentication ))
2017-10-07 13:09:31 +02:00
{
2018-04-12 15:17:15 +02:00
if ( $caneditpassword )
{
$valuetoshow .= ( $valuetoshow ? ( ' ' . $langs -> trans ( " or " ) . ' ' ) : '' ) . '<input size="12" maxlength="32" type="password" class="flat" name="password" value="' . $object -> pass . '" autocomplete="new-password">' ;
}
else
{
2019-01-27 11:55:16 +01:00
$valuetoshow .= ( $valuetoshow ? ( ' ' . $langs -> trans ( " or " ) . ' ' ) : '' ) . preg_replace ( '/./i' , '*' , $object -> pass );
2018-04-12 15:17:15 +02:00
}
2017-10-07 13:09:31 +02:00
}
2018-04-13 09:05:17 +02:00
2018-04-13 09:39:02 +02:00
// Other form for user password
$parameters = array ( 'valuetoshow' => $valuetoshow , 'caneditpassword' => $caneditpassword );
2019-01-27 11:55:16 +01:00
$reshook = $hookmanager -> executeHooks ( 'printUserPasswordField' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
2018-04-13 09:05:17 +02:00
if ( $reshook > 0 ) $valuetoshow = $hookmanager -> resPrint ; // to replace
else $valuetoshow .= $hookmanager -> resPrint ; // to add
2018-04-12 15:17:15 +02:00
print $valuetoshow ;
2017-10-07 13:09:31 +02:00
print " </td></tr> \n " ;
2017-05-19 12:58:38 +02:00
2017-10-07 13:09:31 +02:00
// API key
if ( ! empty ( $conf -> api -> enabled ) && $user -> admin )
{
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>' ;
}
// Administrator
print '<tr><td>' . $langs -> trans ( " Administrator " ) . '</td>' ;
if ( $object -> socid > 0 )
{
$langs -> load ( " admin " );
print '<td>' ;
print '<input type="hidden" name="admin" value="' . $object -> admin . '">' . yn ( $object -> admin );
print ' (' . $langs -> trans ( " ExternalUser " ) . ')' ;
print '</td></tr>' ;
}
else
{
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-05-19 01:41:42 +02: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
)
)
{
2019-01-27 11:55:16 +01:00
print $form -> selectyesno ( 'admin' , $object -> admin , 1 );
2017-10-07 13:09:31 +02:00
2019-02-24 08:21:56 +01:00
if ( ! empty ( $conf -> multicompany -> enabled ) && ! $user -> entity )
2017-10-07 13:09:31 +02:00
{
if ( $conf -> use_javascript_ajax )
{
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
}
$checked = (( $object -> admin && ! $object -> entity ) ? ' checked' : '' );
print '<input type="checkbox" name="superadmin" value="1"' . $checked . ' /> ' . $langs -> trans ( " SuperAdministrator " );
}
}
else
{
$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 ) . '">' ;
2019-01-27 11:55:16 +01:00
if ( ! empty ( $conf -> multicompany -> enabled ) && empty ( $object -> entity )) print $form -> textwithpicto ( $yn , $langs -> trans ( " DontDowngradeSuperAdmin " ), 1 , 'warning' );
2017-10-07 13:09:31 +02:00
else print $yn ;
}
print '</td></tr>' ;
}
2017-05-19 12:58:38 +02:00
2017-10-07 13:09:31 +02:00
// Type
print '<tr><td>' . $langs -> trans ( " Type " ) . '</td>' ;
print '<td>' ;
if ( $user -> id == $object -> id || ! $user -> admin )
{
$type = $langs -> trans ( " Internal " );
if ( $object -> socid ) $type = $langs -> trans ( " External " );
2019-01-27 11:55:16 +01:00
print $form -> textwithpicto ( $type , $langs -> trans ( " InternalExternalDesc " ));
2017-10-07 13:09:31 +02:00
if ( $object -> ldap_sid ) print ' (' . $langs -> trans ( " DomainUser " ) . ')' ;
}
else
2017-05-19 12:58:38 +02:00
{
$type = 0 ;
2018-04-13 09:05:17 +02:00
if ( $object -> contactid ) $type = $object -> contactid ;
2018-11-15 22:01:36 +01:00
print $form -> selectcontacts ( 0 , $type , 'contactid' , 2 , '' , '' , 1 , '' , false , 1 );
2017-10-07 13:09:31 +02:00
if ( $object -> ldap_sid ) print ' (' . $langs -> trans ( " DomainUser " ) . ')' ;
}
print '</td></tr>' ;
2017-05-19 12:58:38 +02:00
2017-12-19 16:16:31 +01:00
// Gender
print '<tr><td>' . $langs -> trans ( " Gender " ) . '</td>' ;
print '<td>' ;
$arraygender = array ( 'man' => $langs -> trans ( " Genderman " ), 'woman' => $langs -> trans ( " Genderwoman " ));
print $form -> selectarray ( 'gender' , $arraygender , GETPOST ( 'gender' ) ? GETPOST ( 'gender' ) : $object -> gender , 1 );
print '</td></tr>' ;
2018-11-15 22:01:36 +01:00
// Employee
print '<tr>' ;
print '<td>' . $form -> editfieldkey ( 'Employee' , 'employee' , '' , $object , 0 ) . '</td><td>' ;
if ( $caneditfield ) {
print $form -> selectyesno ( " employee " , $object -> employee , 1 );
} else {
2018-11-14 18:29:15 +01:00
if ( $object -> employee ){
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 " );
}
}
2018-11-15 22:01:36 +01:00
print '</td></tr>' ;
2017-12-19 16:16:31 +01:00
2018-11-15 22:01:36 +01:00
// Hierarchy
2017-12-19 16:16:31 +01:00
print '<tr><td class="titlefield">' . $langs -> trans ( " HierarchicalResponsible " ) . '</td>' ;
print '<td>' ;
if ( $caneditfield )
{
print $form -> select_dolusers ( $object -> fk_user , 'fk_user' , 1 , array ( $object -> id ), 0 , '' , 0 , $object -> entity , 0 , 0 , '' , 0 , '' , 'maxwidth300' );
}
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 " ;
print '</table><hr><table class="border centpercent">' ;
2017-05-19 12:58:38 +02:00
// Address
2018-10-27 17:45:29 +02:00
print '<tr><td class="tdtop titlefield">' . $form -> editfieldkey ( 'Address' , 'address' , '' , $object , 0 ) . '</td>' ;
2017-10-07 13:09:31 +02:00
print '<td><textarea name="address" id="address" class="quatrevingtpercent" rows="3" wrap="soft">' ;
print $object -> address ;
print '</textarea></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>' ;
2017-10-07 13:09:31 +02:00
print $formcompany -> select_ziptown ( $object -> zip , 'zipcode' , array ( 'town' , 'selectcountry_id' , 'state_id' ), 6 );
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>' ;
2017-10-07 13:09:31 +02:00
print $formcompany -> select_ziptown ( $object -> town , 'town' , array ( 'zipcode' , 'selectcountry_id' , 'state_id' ));
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>' ;
2019-01-27 11:55:16 +01:00
print $form -> select_country (( GETPOST ( 'country_id' ) != '' ? GETPOST ( 'country_id' ) : $object -> country_id ), 'country_id' );
if ( $user -> admin ) print info_admin ( $langs -> trans ( " YouCanChangeValuesForThisListFromDictionarySetup " ), 1 );
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
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>' ;
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>' ;
}
2017-05-19 12:58:38 +02:00
2017-10-07 13:09:31 +02:00
// Tel pro
print " <tr> " . '<td>' . $langs -> trans ( " PhonePro " ) . '</td>' ;
print '<td>' ;
if ( $caneditfield && empty ( $object -> ldap_sid ))
{
print '<input size="20" type="text" name="office_phone" class="flat" value="' . $object -> office_phone . '">' ;
}
else
{
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
print " <tr> " . '<td>' . $langs -> trans ( " PhoneMobile " ) . '</td>' ;
print '<td>' ;
if ( $caneditfield && empty ( $object -> ldap_sid ))
{
print '<input size="20" type="text" name="user_mobile" class="flat" value="' . $object -> user_mobile . '">' ;
}
else
{
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
print " <tr> " . '<td>' . $langs -> trans ( " Fax " ) . '</td>' ;
print '<td>' ;
if ( $caneditfield && empty ( $object -> ldap_sid ))
{
print '<input size="20" type="text" name="office_fax" class="flat" value="' . $object -> office_fax . '">' ;
}
else
{
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
2017-10-07 13:09:31 +02:00
// Skype
2018-10-12 11:02:03 +02:00
if ( ! empty ( $conf -> socialnetworks -> enabled ))
2017-10-07 13:09:31 +02:00
{
print '<tr><td>' . $langs -> trans ( " Skype " ) . '</td>' ;
print '<td>' ;
if ( $caneditfield && empty ( $object -> ldap_sid ))
{
print '<input size="40" type="text" name="skype" class="flat" value="' . $object -> skype . '">' ;
}
else
{
print '<input type="hidden" name="skype" value="' . $object -> skype . '">' ;
print $object -> skype ;
}
print '</td></tr>' ;
}
2017-05-19 12:58:38 +02:00
2018-10-12 11:02:03 +02:00
// Twitter
if ( ! empty ( $conf -> socialnetworks -> enabled ))
{
print '<tr><td>' . $langs -> trans ( " Twitter " ) . '</td>' ;
print '<td>' ;
if ( $caneditfield && empty ( $object -> ldap_sid ))
{
print '<input size="40" type="text" name="twitter" class="flat" value="' . $object -> twitter . '">' ;
}
else
{
print '<input type="hidden" name="twitter" value="' . $object -> twitter . '">' ;
print $object -> twitter ;
}
print '</td></tr>' ;
}
2019-02-25 09:07:58 +01:00
// Facebook
2018-10-12 11:02:03 +02:00
if ( ! empty ( $conf -> socialnetworks -> enabled ))
{
print '<tr><td>' . $langs -> trans ( " Facebook " ) . '</td>' ;
print '<td>' ;
if ( $caneditfield && empty ( $object -> ldap_sid ))
{
print '<input size="40" type="text" name="facebook" class="flat" value="' . $object -> facebook . '">' ;
}
else
{
print '<input type="hidden" name="facebook" value="' . $object -> facebook . '">' ;
print $object -> facebook ;
}
print '</td></tr>' ;
}
2019-02-25 09:07:58 +01:00
// LinkedIn
if ( ! empty ( $conf -> socialnetworks -> enabled ))
{
print '<tr><td>' . $langs -> trans ( " LinkedIn " ) . '</td>' ;
print '<td>' ;
if ( $caneditfield && empty ( $object -> ldap_sid ))
{
print '<input size="40" type="text" name="linkedin" class="flat" value="' . $object -> linkedin . '">' ;
}
else
{
print '<input type="hidden" name="linkedin" value="' . $object -> linkedin . '">' ;
print $object -> linkedin ;
}
print '</td></tr>' ;
}
2017-10-07 13:09:31 +02:00
// EMail
print " <tr> " . '<td' . ( ! empty ( $conf -> global -> USER_MAIL_REQUIRED ) ? ' class="fieldrequired"' : '' ) . '>' . $langs -> trans ( " EMail " ) . '</td>' ;
print '<td>' ;
if ( $caneditfield && empty ( $object -> ldap_sid ))
{
print '<input class="minwidth100" type="text" name="email" class="flat" value="' . $object -> email . '">' ;
}
else
{
print '<input type="hidden" name="email" value="' . $object -> email . '">' ;
print $object -> email ;
}
print '</td></tr>' ;
2017-05-19 12:58:38 +02:00
2017-10-07 13:09:31 +02:00
// OpenID url
2019-01-27 11:55:16 +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>' ;
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>' ;
}
2017-05-19 12:58:38 +02:00
2017-12-19 16:16:31 +01:00
print '</table><hr><table class="border centpercent">' ;
2017-10-07 13:09:31 +02:00
// Accountancy code
if ( $conf -> accounting -> enabled )
{
print " <tr> " ;
print '<td>' . $langs -> trans ( " AccountancyCode " ) . '</td>' ;
print '<td>' ;
if ( $caneditfield )
{
2018-04-13 09:05:17 +02:00
print '<input size="30" type="text" class="flat" name="accountancy_code" value="' . $object -> accountancy_code . '">' ;
2017-10-07 13:09:31 +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
if ( ! empty ( $conf -> agenda -> enabled ))
{
print '<tr><td>' . $langs -> trans ( " ColorUser " ) . '</td>' ;
print '<td>' ;
2018-11-14 18:29:15 +01:00
if ( $caneditfield )
{
print $formother -> selectColor ( GETPOST ( 'color' ) ? GETPOST ( 'color' ) : $object -> color , 'color' , null , 1 , '' , 'hideifnotset' );
} else {
print $formother -> showColor ( $object -> color , '' );
}
2017-10-07 13:09:31 +02:00
print '</td></tr>' ;
}
// Photo
print '<tr>' ;
print '<td>' . $langs -> trans ( " Photo " ) . '</td>' ;
print '<td>' ;
2019-01-27 11:55:16 +01:00
print $form -> showphoto ( 'userphoto' , $object , 60 , 0 , $caneditfield , 'photowithmargin' , 'small' );
2017-10-07 13:09:31 +02:00
print '</td>' ;
print '</tr>' ;
// Categories
2019-02-10 10:45:49 +01:00
if ( ! empty ( $conf -> categorie -> enabled ) && ! empty ( $user -> rights -> categorie -> lire ))
2017-10-07 13:09:31 +02:00
{
2018-10-27 17:45:29 +02:00
print '<tr><td>' . $form -> editfieldkey ( 'Categories' , 'usercats' , '' , $object , 0 ) . '</td>' ;
2017-10-07 13:09:31 +02:00
print '<td>' ;
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 ;
}
2018-11-14 18:29:15 +01:00
if ( $caneditfield )
{
2019-02-10 10:45:49 +01:00
print $form -> multiselectarray ( 'usercats' , $cate_arbo , $arrayselected , '' , 0 , '' , 0 , '90%' );
2018-11-14 18:29:15 +01:00
} else {
2019-02-10 10:45:49 +01:00
print $form -> showCategories ( $object -> id , 'user' , 1 );
2018-11-14 18:29:15 +01:00
}
2017-10-07 13:09:31 +02:00
print " </td></tr> " ;
}
// Status
print '<tr><td>' . $langs -> trans ( " Status " ) . '</td>' ;
print '<td>' ;
print $object -> getLibStatut ( 4 );
print '</td></tr>' ;
// Company / Contact
if ( ! empty ( $conf -> societe -> enabled ))
{
print '<tr><td width="25%">' . $langs -> trans ( " LinkToCompanyContact " ) . '</td>' ;
print '<td>' ;
if ( $object -> socid > 0 )
{
$societe = new Societe ( $db );
$societe -> fetch ( $object -> socid );
2019-01-27 11:55:16 +01:00
print $societe -> getNomUrl ( 1 , '' );
2017-10-07 13:09:31 +02:00
if ( $object -> contactid )
{
$contact = new Contact ( $db );
$contact -> fetch ( $object -> contactid );
2019-01-27 11:55:16 +01:00
print ' / <a href="' . DOL_URL_ROOT . '/contact/card.php?id=' . $object -> contactid . '">' . img_object ( $langs -> trans ( " ShowContact " ), 'contact' ) . ' ' . dol_trunc ( $contact -> getFullName ( $langs ), 32 ) . '</a>' ;
2017-10-07 13:09:31 +02:00
}
}
else
{
print $langs -> trans ( " ThisUserIsNot " );
}
print ' (' . $langs -> trans ( " UseTypeFieldToChange " ) . ')' ;
print '</td>' ;
print " </tr> \n " ;
}
// Module Adherent
if ( ! empty ( $conf -> adherent -> enabled ))
{
$langs -> load ( " members " );
print '<tr><td width="25%">' . $langs -> trans ( " LinkedToDolibarrMember " ) . '</td>' ;
print '<td>' ;
if ( $object -> fk_member )
{
$adh = new Adherent ( $db );
$adh -> fetch ( $object -> fk_member );
$adh -> ref = $adh -> login ; // Force to show login instead of id
print $adh -> getNomUrl ( 1 );
}
else
{
print $langs -> trans ( " UserNotLinkedToMember " );
}
print '</td>' ;
print " </tr> \n " ;
}
2009-05-07 01:30:49 +02:00
2018-07-05 22:15:55 +02:00
// Multicompany
2017-08-25 13:25:34 +02:00
// TODO check if user not linked with the current entity before change entity (thirdparty, invoice, etc.) !!
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
if ( ! method_exists ( $mc , 'formObjectOptions' ))
2017-08-25 13:25:34 +02:00
{
2018-07-05 22:15:55 +02:00
if ( empty ( $conf -> multicompany -> transverse_mode ) && $conf -> entity == 1 && $user -> admin && ! $user -> entity )
{
print " <tr> " . '<td>' . $langs -> trans ( " Entity " ) . '</td>' ;
2019-05-19 01:41:42 +02:00
print " <td> " . $mc -> select_entities ( $object -> entity , 'entity' , '' , 0 , 1 , false , false , 1 ); // last parameter 1 means, show also a choice 0=>'all entities'
2018-07-05 22:15:55 +02:00
print " </td></tr> \n " ;
}
else
{
print '<input type="hidden" name="entity" value="' . $conf -> entity . '" />' ;
}
}
}
2017-08-25 13:25:34 +02:00
2017-10-07 13:09:31 +02:00
// Other attributes
$parameters = array ( 'colspan' => ' colspan="2"' );
2019-01-27 11:55:16 +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 ;
2018-04-13 13:28:48 +02:00
if ( empty ( $reshook ))
2017-10-07 13:09:31 +02:00
{
2018-11-14 18:29:15 +01:00
if ( $caneditfield )
{
2019-01-27 11:55:16 +01:00
print $object -> showOptionals ( $extrafields , 'edit' );
2018-11-14 18:29:15 +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>' ;
if ( $caneditfield )
{
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php' ;
2019-01-27 11:55:16 +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 );
}
else
{
print dol_htmlentitiesbr ( $object -> signature );
}
print '</td></tr>' ;
2017-06-06 07:57:03 +02:00
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)
// Position/Job
print '<tr><td class="titlefield">' . $langs -> trans ( " PostOrFunction " ) . '</td>' ;
print '<td>' ;
if ( $caneditfield )
{
print '<input size="30" type="text" name="job" value="' . $object -> job . '">' ;
}
else
{
print '<input type="hidden" name="job" value="' . $object -> job . '">' ;
print $object -> job ;
}
print '</td></tr>' ;
2019-02-27 13:48:13 +01:00
2019-02-15 05:24:25 +01:00
// Default warehouse
if ( ! empty ( $conf -> stock -> enabled ))
{
print '<tr><td>' . $langs -> trans ( " DefaultWarehouse " ) . '</td><td>' ;
print $formproduct -> selectWarehouses ( $object -> fk_warehouse , 'fk_warehouse' , 'warehouseopen' , 1 );
2019-02-15 06:04:58 +01:00
print ' <a href="' . DOL_URL_ROOT . '/product/stock/card.php?action=create&backtopage=' . urlencode ( $_SERVER [ 'PHP_SELF' ] . '?id=' . $object -> id . '&action=edit' ) . '">' . $langs -> trans ( " AddWarehouse " ) . '</a>' ;
2019-02-15 17:12:39 +01:00
print '</td></tr>' ;
2019-02-15 05:24:25 +01:00
}
2017-12-19 16:16:31 +01:00
if (( ! empty ( $conf -> salaries -> enabled ) && ! empty ( $user -> rights -> salaries -> read ))
|| ( ! empty ( $conf -> hrm -> enabled ) && ! empty ( $user -> rights -> hrm -> employee -> read )))
{
$langs -> load ( " salaries " );
// THM
print '<tr><td>' ;
$text = $langs -> trans ( " THM " );
print $form -> textwithpicto ( $text , $langs -> trans ( " THMDescription " ), 1 , 'help' , 'classthm' );
print '</td>' ;
print '<td>' ;
2018-11-14 18:29:15 +01:00
if ( $caneditfield ){
print '<input size="8" type="text" name="thm" value="' . price2num ( GETPOST ( 'thm' ) ? GETPOST ( 'thm' ) : $object -> thm ) . '">' ;
} else {
2019-01-27 11:55:16 +01:00
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>' ;
$text = $langs -> trans ( " TJM " );
print $form -> textwithpicto ( $text , $langs -> trans ( " TJMDescription " ), 1 , 'help' , 'classthm' );
print '</td>' ;
print '<td>' ;
2018-11-14 18:29:15 +01:00
if ( $caneditfield )
{
print '<input size="8" type="text" name="tjm" value="' . price2num ( GETPOST ( 'tjm' ) ? GETPOST ( 'tjm' ) : $object -> tjm ) . '">' ;
} else {
2019-01-27 11:55:16 +01:00
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 " ;
// Salary
print '<tr><td>' . $langs -> trans ( " Salary " ) . '</td>' ;
print '<td>' ;
print '<input size="8" type="text" name="salary" value="' . price2num ( GETPOST ( 'salary' ) ? GETPOST ( 'salary' ) : $object -> salary ) . '">' ;
print '</td>' ;
print " </tr> \n " ;
}
// Weeklyhours
print '<tr><td>' . $langs -> trans ( " WeeklyHours " ) . '</td>' ;
print '<td>' ;
2018-11-14 18:29:15 +01:00
if ( $caneditfield )
{
print '<input size="8" type="text" name="weeklyhours" value="' . price2num ( GETPOST ( 'weeklyhours' ) ? GETPOST ( 'weeklyhours' ) : $object -> weeklyhours ) . '">' ;
} else {
print price2num ( $object -> 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>' ;
2018-11-14 18:29:15 +01:00
if ( $caneditfield )
{
print $form -> selectDate ( GETPOST ( 'dateemployment' ) ? GETPOST ( 'dateemployment' ) : $object -> dateemployment , 'dateemployment' , 0 , 0 , 1 , 'formdateemployment' , 1 , 0 );
} else {
print dol_print_date ( $object -> dateemployment , 'day' );
}
2017-12-19 16:16:31 +01:00
print '</td>' ;
print " </tr> \n " ;
2018-05-12 18:05:06 +02:00
// Date employmentEnd
print '<tr><td>' . $langs -> trans ( " DateEmploymentEnd " ) . '</td>' ;
print '<td>' ;
2018-11-14 18:29:15 +01:00
if ( $caneditfield )
{
print $form -> selectDate ( GETPOST ( 'dateemploymentend' ) ? GETPOST ( 'dateemploymentend' ) : $object -> dateemploymentend , 'dateemploymentend' , 0 , 0 , 1 , 'formdateemploymentend' , 1 , 0 );
} else {
print dol_print_date ( $object -> dateemploymentend , 'day' );
}
2018-05-12 18:05:06 +02:00
print '</td>' ;
print " </tr> \n " ;
2017-12-19 16:16:31 +01:00
// Date birth
print '<tr><td>' . $langs -> trans ( " DateToBirth " ) . '</td>' ;
print '<td>' ;
2018-11-14 18:29:15 +01:00
if ( $caneditfield )
{
2018-11-15 16:56:12 +01:00
echo $form -> selectDate ( GETPOST ( 'birth' ) ? GETPOST ( 'birth' ) : $object -> birth , 'birth' , 0 , 0 , 1 , 'updateuser' , 1 , 0 );
2018-11-14 18:29:15 +01:00
} else {
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
2017-10-07 13:09:31 +02:00
dol_fiche_end ();
2015-05-04 11:41:30 +02:00
2019-02-16 10:29:15 +01:00
print '<div class="center">' ;
2017-10-07 13:09:31 +02:00
print '<input value="' . $langs -> trans ( " Save " ) . '" class="button" type="submit" name="save">' ;
print ' ' ;
print '<input value="' . $langs -> trans ( " Cancel " ) . '" class="button" type="submit" name="cancel">' ;
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
2017-10-08 16:34:42 +02:00
if ( $action != 'edit' && $action != 'presend' )
2017-10-07 13:09:31 +02:00
{
print '<div class="fichecenter"><div class="fichehalfleft">' ;
/*
2017-04-01 00:35:05 +02:00
* Documents generes
2018-05-24 12:16:04 +02:00
*/
2017-10-07 13:09:31 +02:00
$filename = dol_sanitizeFileName ( $object -> ref );
$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
2017-10-07 13:09:31 +02:00
print $formfile -> showdocuments ( 'user' , $filename , $filedir , $urlsource , $genallowed , $delallowed , $object -> modelpdf , 1 , 0 , 0 , 28 , 0 , '' , 0 , '' , $soc -> default_lang );
$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
2017-10-07 13:09:31 +02:00
print '</div><div class="fichehalfright"><div class="ficheaddleft">' ;
2017-06-06 07:57:03 +02:00
2017-10-07 13:09:31 +02:00
// List of actions on element
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php' ;
$formactions = new FormActions ( $db );
$somethingshown = $formactions -> showactions ( $object , 'user' , $socid , 1 );
2017-06-06 07:57:03 +02:00
2017-10-07 13:09:31 +02:00
print '</div></div></div>' ;
}
2017-06-06 07:57:03 +02:00
2017-04-01 00:35:05 +02:00
if ( ! empty ( $conf -> ldap -> enabled ) && ! empty ( $object -> ldap_sid )) $ldap -> close ();
2017-10-07 13:09:31 +02:00
}
2002-05-06 21:10:48 +02:00
}
2015-06-15 14:38:02 +02:00
if ( ! empty ( $conf -> api -> enabled ) && ! empty ( $conf -> use_javascript_ajax ))
2015-05-29 16:05:52 +02:00
{
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 ();