2004-10-20 23:06:45 +02:00
< ? php
2005-08-23 13:40:19 +02:00
/* Copyright ( C ) 2002 - 2005 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2021-12-12 23:47:40 +01:00
* Copyright ( C ) 2004 - 2021 Laurent Destailleur < eldy @ users . sourceforge . net >
2018-10-27 14:43:12 +02:00
* Copyright ( C ) 2005 - 2017 Regis Houssin < regis . houssin @ inodbox . com >
2019-01-28 21:39:22 +01:00
* Copyright ( C ) 2015 Alexandre Spangaro < aspangaro @ open - dsi . fr >
2016-04-10 01:00:27 +02:00
* Copyright ( C ) 2016 Marcos García < marcosgdf @ gmail . com >
2002-05-06 21:10:48 +02:00
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
2013-01-16 15:36:08 +01:00
* the Free Software Foundation ; either version 3 of the License , or
2002-05-06 21:10:48 +02:00
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
2019-09-23 21:55:30 +02:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
2002-05-06 21:10:48 +02:00
*/
2009-01-31 01:15:34 +01:00
2005-01-18 20:44:23 +01:00
/**
2018-04-06 00:36:52 +02:00
* \file htdocs / user / list . php
2009-06-04 01:05:52 +02:00
* \ingroup core
2011-05-25 11:51:01 +02:00
* \brief Page of users
2009-06-04 01:05:52 +02:00
*/
2004-11-03 23:00:47 +01:00
2012-08-22 23:24:21 +02:00
require '../main.inc.php' ;
2018-10-09 01:01:58 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php' ;
2020-01-30 01:48:28 +01:00
if ( ! empty ( $conf -> categorie -> enabled )) {
2018-10-09 01:01:58 +02:00
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php' ;
2019-10-27 10:38:52 +01:00
}
2002-05-06 21:10:48 +02:00
2019-10-27 10:38:52 +01:00
// Load translation files required by page
2021-01-03 14:54:35 +01:00
$langs -> loadLangs ( array ( 'users' , 'companies' , 'hrm' , 'salaries' ));
2004-07-31 17:42:28 +02:00
2020-10-01 16:21:07 +02:00
$action = GETPOST ( 'action' , 'aZ09' ) ? GETPOST ( 'action' , 'aZ09' ) : 'view' ; // The action 'add', 'create', 'edit', 'update', 'view', ...
$massaction = GETPOST ( 'massaction' , 'alpha' ); // The bulk action (combo box choice into lists)
$show_files = GETPOST ( 'show_files' , 'int' ); // Show files area generated by bulk actions ?
$confirm = GETPOST ( 'confirm' , 'alpha' ); // Result of a confirmation
$cancel = GETPOST ( 'cancel' , 'alpha' ); // We click on a Cancel button
$toselect = GETPOST ( 'toselect' , 'array' ); // Array of ids of elements selected into a list
2020-01-30 01:48:28 +01:00
$contextpage = GETPOST ( 'contextpage' , 'aZ' ) ? GETPOST ( 'contextpage' , 'aZ' ) : 'userlist' ; // To manage different context of search
2020-10-01 16:21:07 +02:00
$backtopage = GETPOST ( 'backtopage' , 'alpha' ); // Go back to a dedicated page
$optioncss = GETPOST ( 'optioncss' , 'aZ' ); // Option for the css output (always '' except when 'print')
2018-03-31 18:48:27 +02:00
2010-10-29 18:08:54 +02:00
// Security check (for external users)
2020-01-30 01:48:28 +01:00
$socid = 0 ;
2019-10-31 20:46:31 +01:00
if ( $user -> socid > 0 ) {
$socid = $user -> socid ;
2019-10-27 10:38:52 +01:00
}
2010-10-29 18:08:54 +02:00
2015-11-17 22:51:34 +01:00
// Load mode employee
$mode = GETPOST ( " mode " , 'alpha' );
2015-11-05 13:43:22 +01:00
// Load variable for pagination
2019-11-13 19:35:39 +01:00
$limit = GETPOST ( 'limit' , 'int' ) ? GETPOST ( 'limit' , 'int' ) : $conf -> liste_limit ;
2020-09-18 17:13:01 +02:00
$sortfield = GETPOST ( 'sortfield' , 'aZ09comma' );
2020-09-17 14:31:25 +02:00
$sortorder = GETPOST ( 'sortorder' , 'aZ09comma' );
2020-03-13 13:07:11 +01:00
$page = GETPOSTISSET ( 'pageplusone' ) ? ( GETPOST ( 'pageplusone' ) - 1 ) : GETPOST ( " page " , 'int' );
2021-02-26 13:18:40 +01:00
if ( empty ( $page ) || $page < 0 || GETPOST ( 'button_search' , 'alpha' ) || GETPOST ( 'button_removefilter' , 'alpha' )) {
$page = 0 ;
} // If $page is not defined, or '' or -1 or if we click on clear filters
2015-10-29 22:12:11 +01:00
$offset = $limit * $page ;
2010-11-20 14:08:44 +01:00
$pageprev = $page - 1 ;
$pagenext = $page + 1 ;
2018-04-12 18:05:12 +02:00
2017-06-10 12:56:28 +02:00
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
2018-03-31 18:48:27 +02:00
$object = new User ( $db );
2015-10-25 18:15:37 +01:00
$extrafields = new ExtraFields ( $db );
2021-05-20 14:18:00 +02:00
$diroutputmassaction = $conf -> user -> dir_output . '/temp/massgeneration/' . $user -> id ;
2020-10-01 16:21:07 +02:00
$hookmanager -> initHooks ( array ( 'userlist' ));
2015-10-25 18:15:37 +01:00
2020-10-01 16:21:07 +02:00
// Fetch optionals attributes and labels
2019-10-06 14:41:52 +02:00
$extrafields -> fetch_name_optionals_label ( $object -> table_element );
2020-10-01 16:21:07 +02:00
2019-11-13 19:35:39 +01:00
$search_array_options = $extrafields -> getOptionalsFromPost ( $object -> table_element , '' , 'search_' );
2015-10-25 18:15:37 +01:00
2021-02-26 13:18:40 +01:00
if ( ! $sortfield ) {
$sortfield = " u.login " ;
}
if ( ! $sortorder ) {
$sortorder = " ASC " ;
}
2020-10-01 16:21:07 +02:00
// Initialize array of search criterias
$search_all = GETPOST ( 'search_all' , 'alphanohtml' ) ? GETPOST ( 'search_all' , 'alphanohtml' ) : GETPOST ( 'sall' , 'alphanohtml' );
$search = array ();
2021-02-26 13:18:40 +01:00
foreach ( $object -> fields as $key => $val ) {
if ( GETPOST ( 'search_' . $key , 'alpha' ) !== '' ) {
$search [ $key ] = GETPOST ( 'search_' . $key , 'alpha' );
}
2020-10-01 16:21:07 +02:00
}
2019-11-13 19:35:39 +01:00
$userstatic = new User ( $db );
2010-10-29 18:08:54 +02:00
$companystatic = new Societe ( $db );
2013-11-17 17:09:58 +01:00
$form = new Form ( $db );
2007-02-26 01:00:03 +01:00
2015-10-25 18:15:37 +01:00
// List of fields to search into when doing a "search in all"
$fieldstosearchall = array (
'u.login' => " Login " ,
2017-10-13 13:28:26 +02:00
'u.lastname' => " Lastname " ,
'u.firstname' => " Firstname " ,
2015-10-25 18:15:37 +01:00
'u.accountancy_code' => " AccountancyCode " ,
2021-01-13 18:52:27 +01:00
'u.office_phone' => " PhonePro " ,
'u.user_mobile' => " PhoneMobile " ,
2015-10-25 18:15:37 +01:00
'u.email' => " EMail " ,
2019-07-18 14:08:15 +02:00
'u.note' => " Note " ,
2015-10-25 18:15:37 +01:00
);
2021-02-26 13:18:40 +01:00
if ( ! empty ( $conf -> api -> enabled )) {
2019-11-13 19:35:39 +01:00
$fieldstosearchall [ 'u.api_key' ] = " ApiKey " ;
2019-07-18 14:08:15 +02:00
}
2015-10-25 18:15:37 +01:00
2015-11-11 17:05:18 +01:00
// Definition of fields for list
2019-11-13 19:35:39 +01:00
$arrayfields = array (
2020-12-03 00:40:41 +01:00
'u.login' => array ( 'label' => " Login " , 'checked' => 1 , 'position' => 10 ),
2021-02-26 13:18:40 +01:00
'u.lastname' => array ( 'label' => " Lastname " , 'checked' => 1 , 'position' => 15 ),
'u.firstname' => array ( 'label' => " Firstname " , 'checked' => 1 , 'position' => 20 ),
'u.entity' => array ( 'label' => " Entity " , 'checked' => 1 , 'position' => 50 , 'enabled' => ( ! empty ( $conf -> multicompany -> enabled ) && empty ( $conf -> global -> MULTICOMPANY_TRANSVERSE_MODE ))),
'u.gender' => array ( 'label' => " Gender " , 'checked' => 0 , 'position' => 22 ),
'u.employee' => array ( 'label' => " Employee " , 'checked' => ( $mode == 'employee' ? 1 : 0 ), 'position' => 25 ),
'u.fk_user' => array ( 'label' => " HierarchicalResponsible " , 'checked' => 1 , 'position' => 27 ),
'u.accountancy_code' => array ( 'label' => " AccountancyCode " , 'checked' => 0 , 'position' => 30 ),
2021-01-13 18:52:27 +01:00
'u.office_phone' => array ( 'label' => " PhonePro " , 'checked' => 1 , 'position' => 31 ),
'u.user_mobile' => array ( 'label' => " PhoneMobile " , 'checked' => 1 , 'position' => 32 ),
2021-02-26 13:18:40 +01:00
'u.email' => array ( 'label' => " EMail " , 'checked' => 1 , 'position' => 35 ),
2021-05-18 20:13:26 +02:00
'u.api_key' => array ( 'label' => " ApiKey " , 'checked' => 0 , 'position' => 40 , " enabled " => ( ! empty ( $conf -> api -> enabled ) && $user -> admin )),
2021-02-26 13:18:40 +01:00
'u.fk_soc' => array ( 'label' => " Company " , 'checked' => ( $contextpage == 'employeelist' ? 0 : 1 ), 'position' => 45 ),
2021-05-18 20:13:26 +02:00
'u.salary' => array ( 'label' => " Salary " , 'checked' => 1 , 'position' => 80 , 'enabled' => ( ! empty ( $conf -> salaries -> enabled ) && ! empty ( $user -> rights -> salaries -> readall ))),
2021-02-26 13:18:40 +01:00
'u.datelastlogin' => array ( 'label' => " LastConnexion " , 'checked' => 1 , 'position' => 100 ),
2020-12-03 00:40:41 +01:00
'u.datepreviouslogin' => array ( 'label' => " PreviousConnexion " , 'checked' => 0 , 'position' => 110 ),
'u.datec' => array ( 'label' => " DateCreation " , 'checked' => 0 , 'position' => 500 ),
'u.tms' => array ( 'label' => " DateModificationShort " , 'checked' => 0 , 'position' => 500 ),
'u.statut' => array ( 'label' => " Status " , 'checked' => 1 , 'position' => 1000 ),
2015-11-11 17:05:18 +01:00
);
// Extra fields
2020-12-03 00:40:41 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_array_fields.tpl.php' ;
2019-10-22 17:08:37 +02:00
$object -> fields = dol_sort_array ( $object -> fields , 'position' );
$arrayfields = dol_sort_array ( $arrayfields , 'position' );
2015-11-11 17:05:18 +01:00
// Init search fields
2020-12-03 00:40:41 +01:00
$sall = trim (( GETPOST ( 'search_all' , 'alphanohtml' ) != '' ) ? GETPOST ( 'search_all' , 'alphanohtml' ) : GETPOST ( 'sall' , 'alphanohtml' ));
2020-01-30 01:48:28 +01:00
$search_user = GETPOST ( 'search_user' , 'alpha' );
$search_login = GETPOST ( 'search_login' , 'alpha' );
$search_lastname = GETPOST ( 'search_lastname' , 'alpha' );
$search_firstname = GETPOST ( 'search_firstname' , 'alpha' );
$search_gender = GETPOST ( 'search_gender' , 'alpha' );
$search_employee = GETPOST ( 'search_employee' , 'alpha' );
$search_accountancy_code = GETPOST ( 'search_accountancy_code' , 'alpha' );
2021-01-13 18:52:27 +01:00
$search_phonepro = GETPOST ( 'search_phonepro' , 'alpha' );
$search_phonemobile = GETPOST ( 'search_phonemobile' , 'alpha' );
2020-01-30 01:48:28 +01:00
$search_email = GETPOST ( 'search_email' , 'alpha' );
$search_api_key = GETPOST ( 'search_api_key' , 'alphanohtml' );
$search_statut = GETPOST ( 'search_statut' , 'intcomma' );
$search_thirdparty = GETPOST ( 'search_thirdparty' , 'alpha' );
2021-05-06 15:34:45 +02:00
$search_warehouse = GETPOST ( 'search_warehouse' , 'alpha' );
2020-01-30 01:48:28 +01:00
$search_supervisor = GETPOST ( 'search_supervisor' , 'intcomma' );
2019-01-27 11:55:16 +01:00
$optioncss = GETPOST ( 'optioncss' , 'alpha' );
$search_categ = GETPOST ( " search_categ " , 'int' );
$catid = GETPOST ( 'catid' , 'int' );
2015-11-11 17:05:18 +01:00
// Default search
2021-02-26 13:18:40 +01:00
if ( $search_statut == '' ) {
$search_statut = '1' ;
}
if ( $mode == 'employee' && ! GETPOSTISSET ( 'search_employee' )) {
$search_employee = 1 ;
}
2015-11-11 17:05:18 +01:00
2020-10-01 16:21:07 +02:00
// Define value to know what current user can do on users
$permissiontoadd = ( ! empty ( $user -> admin ) || $user -> rights -> user -> user -> creer );
$canreaduser = ( ! empty ( $user -> admin ) || $user -> rights -> user -> user -> lire );
$canedituser = ( ! empty ( $user -> admin ) || $user -> rights -> user -> user -> creer );
$candisableuser = ( ! empty ( $user -> admin ) || $user -> rights -> user -> user -> supprimer );
$canreadgroup = $canreaduser ;
$caneditgroup = $canedituser ;
2021-02-26 13:18:40 +01:00
if ( ! empty ( $conf -> global -> MAIN_USE_ADVANCED_PERMS )) {
2020-10-01 16:21:07 +02:00
$canreadgroup = ( ! empty ( $user -> admin ) || $user -> rights -> user -> group_advance -> read );
$caneditgroup = ( ! empty ( $user -> admin ) || $user -> rights -> user -> group_advance -> write );
}
$error = 0 ;
2015-11-11 17:05:18 +01:00
2021-05-06 11:25:46 +02:00
// Permission to list
if ( $mode == 'employee' ) {
if ( empty ( $user -> rights -> salaries -> read )) {
accessforbidden ();
}
} else {
2021-05-24 19:05:25 +02:00
if ( empty ( $user -> rights -> user -> user -> lire ) && empty ( $user -> admin )) {
2021-05-06 11:25:46 +02:00
accessforbidden ();
}
2021-03-19 15:05:28 +01:00
}
2020-12-03 00:40:41 +01:00
$childids = $user -> getAllChildIds ( 1 );
2015-10-25 18:15:37 +01:00
/*
* Actions
*/
2016-11-02 12:48:50 +01:00
2021-02-26 13:18:40 +01:00
if ( GETPOST ( 'cancel' , 'alpha' )) {
$action = 'list' ; $massaction = '' ;
}
2022-04-25 14:28:57 +02:00
if ( ! GETPOST ( 'confirmmassaction' , 'alpha' ) && $massaction != 'presend' && $massaction != 'confirm_presend' ) {
2021-02-26 13:18:40 +01:00
$massaction = '' ;
}
2016-11-02 12:48:50 +01:00
2019-11-13 19:35:39 +01:00
$parameters = array ();
2020-10-01 16:21:07 +02:00
$reshook = $hookmanager -> executeHooks ( 'doActions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by some hooks
2021-02-26 13:18:40 +01:00
if ( $reshook < 0 ) {
setEventMessages ( $hookmanager -> error , $hookmanager -> errors , 'errors' );
}
2015-10-25 18:15:37 +01:00
2021-02-26 13:18:40 +01:00
if ( empty ( $reshook )) {
2017-10-13 13:28:26 +02:00
// Selection of new fields
include DOL_DOCUMENT_ROOT . '/core/actions_changeselectedfields.inc.php' ;
// Purge search criteria
2021-02-26 13:18:40 +01:00
if ( GETPOST ( 'button_removefilter_x' , 'alpha' ) || GETPOST ( 'button_removefilter.x' , 'alpha' ) || GETPOST ( 'button_removefilter' , 'alpha' )) { // All tests are required to be compatible with all browsers
2019-11-13 19:35:39 +01:00
$search_user = " " ;
$search_login = " " ;
$search_lastname = " " ;
$search_firstname = " " ;
$search_gender = " " ;
$search_employee = " " ;
$search_accountancy_code = " " ;
2021-01-13 18:52:27 +01:00
$search_phonepro = " " ;
$search_phonemobile = " " ;
2019-11-13 19:35:39 +01:00
$search_email = " " ;
$search_statut = " " ;
$search_thirdparty = " " ;
2021-05-06 15:34:45 +02:00
$search_warehouse = " " ;
2019-11-13 19:35:39 +01:00
$search_supervisor = " " ;
$search_api_key = " " ;
$search_datelastlogin = " " ;
$search_datepreviouslogin = " " ;
$search_date_creation = " " ;
$search_date_update = " " ;
$search_array_options = array ();
2020-10-07 15:01:28 +02:00
$search_categ = 0 ;
2017-10-13 13:28:26 +02:00
}
2020-10-01 16:21:07 +02:00
// Mass actions
$objectclass = 'User' ;
$objectlabel = 'User' ;
$uploaddir = $conf -> user -> dir_output ;
include DOL_DOCUMENT_ROOT . '/core/actions_massactions.inc.php' ;
// Disable or Enable records
2021-02-26 13:18:40 +01:00
if ( ! $error && ( $massaction == 'disable' || $massaction == 'reactivate' ) && $permissiontoadd ) {
2020-10-01 16:21:07 +02:00
$objecttmp = new User ( $db );
2021-02-26 13:18:40 +01:00
if ( ! $error ) {
2020-10-01 16:21:07 +02:00
$db -> begin ();
$nbok = 0 ;
2021-02-26 13:18:40 +01:00
foreach ( $toselect as $toselectid ) {
2020-10-01 16:21:07 +02:00
if ( $toselectid == $user -> id ) {
setEventMessages ( $langs -> trans ( $massaction == 0 ? 'CantDisableYourself' : 'CanEnableYourself' ), null , 'errors' );
$error ++ ;
break ;
}
$result = $objecttmp -> fetch ( $toselectid );
if ( $result > 0 ) {
if ( $objecttmp -> admin ) {
setEventMessages ( $langs -> trans ( $massaction == 0 ? 'CantDisableAnAdminUserWithMassActions' : 'CantEnableAnAdminUserWithMassActions' , $objecttmp -> login ), null , 'errors' );
$error ++ ;
break ;
}
$result = $objecttmp -> setstatus ( $massaction == 'disable' ? 0 : 1 );
if ( $result == 0 ) {
// Nothing is done
} elseif ( $result < 0 ) {
setEventMessages ( $objecttmp -> error , $objecttmp -> errors , 'errors' );
$error ++ ;
break ;
2021-02-26 13:18:40 +01:00
} else {
$nbok ++ ;
}
2020-10-01 16:21:07 +02:00
} else {
setEventMessages ( $objecttmp -> error , $objecttmp -> errors , 'errors' );
$error ++ ;
break ;
}
}
if ( ! $error && ! empty ( $conf -> file -> main_limit_users )) {
$nb = $object -> getNbOfUsers ( " active " );
if ( $nb >= $conf -> file -> main_limit_users ) {
$error ++ ;
setEventMessages ( $langs -> trans ( " YourQuotaOfUsersIsReached " ), null , 'errors' );
}
}
2021-02-26 13:18:40 +01:00
if ( ! $error ) {
if ( $nbok > 1 ) {
setEventMessages ( $langs -> trans ( " RecordsModified " , $nbok ), null , 'mesgs' );
} else {
setEventMessages ( $langs -> trans ( " RecordsModified " , $nbok ), null , 'mesgs' );
}
2020-10-01 16:21:07 +02:00
$db -> commit ();
} else {
$db -> rollback ();
}
}
}
2015-11-05 13:43:22 +01:00
}
2015-10-25 18:15:37 +01:00
2009-01-31 01:15:34 +01:00
/*
* View
*/
2005-01-31 17:21:47 +01:00
2020-10-01 16:21:07 +02:00
$formother = new FormOther ( $db );
2021-03-15 16:58:59 +01:00
$help_url = 'EN:Module_Users|FR:Module_Utilisateurs|ES:Módulo_Usuarios|DE:Modul_Benutzer' ;
2020-11-24 14:15:43 +01:00
if ( $contextpage == 'employeelist' && $search_employee == 1 ) {
$text = $langs -> trans ( " ListOfEmployees " );
} else {
$text = $langs -> trans ( " ListOfUsers " );
}
2018-10-09 01:01:58 +02:00
2020-01-30 01:48:28 +01:00
$user2 = new User ( $db );
2004-07-31 17:42:28 +02:00
2021-01-13 18:52:27 +01:00
$sql = " SELECT DISTINCT u.rowid, u.lastname, u.firstname, u.admin, u.fk_soc, u.login, u.office_phone, u.user_mobile, u.email, u.api_key, u.accountancy_code, u.gender, u.employee, u.photo, " ;
2020-12-03 00:40:41 +01:00
$sql .= " u.salary, u.datelastlogin, u.datepreviouslogin, " ;
2020-01-30 01:48:28 +01:00
$sql .= " u.ldap_sid, u.statut, u.entity, " ;
$sql .= " u.tms as date_update, u.datec as date_creation, " ;
2021-01-13 18:52:27 +01:00
$sql .= " u2.rowid as id2, u2.login as login2, u2.firstname as firstname2, u2.lastname as lastname2, u2.admin as admin2, u2.fk_soc as fk_soc2, u2.office_phone as ofice_phone2, u2.user_mobile as user_mobile2, u2.email as email2, u2.gender as gender2, u2.photo as photo2, u2.entity as entity2, u2.statut as statut2, " ;
2021-01-27 21:09:01 +01:00
$sql .= " s.nom as name, s.canvas, " ;
2015-10-25 18:15:37 +01:00
// Add fields from extrafields
2020-01-30 01:48:28 +01:00
if ( ! empty ( $extrafields -> attributes [ $object -> table_element ][ 'label' ])) {
2021-01-27 21:04:48 +01:00
foreach ( $extrafields -> attributes [ $object -> table_element ][ 'label' ] as $key => $val ) {
2021-08-27 22:42:04 +02:00
$sql .= ( $extrafields -> attributes [ $object -> table_element ][ 'type' ][ $key ] != 'separate' ? " ef. " . $key . " as options_ " . $key . ', ' : '' );
2021-01-27 21:04:48 +01:00
}
2019-10-16 03:34:32 +02:00
}
2015-10-25 18:15:37 +01:00
// Add fields from hooks
2020-01-30 01:48:28 +01:00
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'printFieldListSelect' , $parameters ); // Note that $action and $object may have been modified by hook
2020-10-01 16:21:07 +02:00
$sql .= preg_replace ( '/^,/' , '' , $hookmanager -> resPrint );
$sql = preg_replace ( '/,\s*$/' , '' , $sql );
2020-01-30 01:48:28 +01:00
$sql .= " FROM " . MAIN_DB_PREFIX . " user as u " ;
2021-05-18 20:13:26 +02:00
if ( key_exists ( 'label' , $extrafields -> attributes [ $object -> table_element ]) && is_array ( $extrafields -> attributes [ $object -> table_element ][ 'label' ]) && count ( $extrafields -> attributes [ $object -> table_element ][ 'label' ])) {
2021-01-27 21:04:48 +01:00
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . $object -> table_element . " _extrafields as ef on (u.rowid = ef.fk_object) " ;
}
2020-01-30 01:48:28 +01:00
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " societe as s ON u.fk_soc = s.rowid " ;
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " user as u2 ON u.fk_user = u2.rowid " ;
2021-02-26 13:18:40 +01:00
if ( ! empty ( $search_categ ) || ! empty ( $catid )) {
$sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . " categorie_user as cu ON u.rowid = cu.fk_user " ; // We'll need this table joined to the select in order to filter by categ
}
2018-03-23 10:42:36 +01:00
// Add fields from hooks
2020-01-30 01:48:28 +01:00
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'printUserListWhere' , $parameters ); // Note that $action and $object may have been modified by hook
2018-03-23 10:52:10 +01:00
if ( $reshook > 0 ) {
2020-01-30 01:48:28 +01:00
$sql .= $hookmanager -> resPrint ;
2018-03-06 19:22:59 +01:00
} else {
2020-01-30 01:48:28 +01:00
$sql .= " WHERE u.entity IN ( " . getEntity ( 'user' ) . " ) " ;
2011-08-20 00:15:22 +02:00
}
2021-02-26 13:18:40 +01:00
if ( $socid > 0 ) {
2021-03-22 13:31:06 +01:00
$sql .= " AND u.fk_soc = " . (( int ) $socid );
2021-02-26 13:18:40 +01:00
}
2015-10-26 12:16:40 +01:00
//if ($search_user != '') $sql.=natural_search(array('u.login', 'u.lastname', 'u.firstname'), $search_user);
2021-02-26 13:18:40 +01:00
if ( $search_supervisor > 0 ) {
2021-03-22 11:30:18 +01:00
$sql .= " AND u.fk_user IN ( " . $db -> sanitize ( $search_supervisor ) . " ) " ;
2021-02-26 13:18:40 +01:00
}
if ( $search_thirdparty != '' ) {
$sql .= natural_search ( array ( 's.nom' ), $search_thirdparty );
}
2021-09-21 09:13:01 +02:00
if ( $search_warehouse > 0 ) {
2021-05-06 15:34:45 +02:00
$sql .= natural_search ( array ( 'u.fk_warehouse' ), $search_warehouse );
}
2021-02-26 13:18:40 +01:00
if ( $search_login != '' ) {
$sql .= natural_search ( " u.login " , $search_login );
}
if ( $search_lastname != '' ) {
$sql .= natural_search ( " u.lastname " , $search_lastname );
}
if ( $search_firstname != '' ) {
$sql .= natural_search ( " u.firstname " , $search_firstname );
}
if ( $search_gender != '' && $search_gender != '-1' ) {
$sql .= " AND u.gender = ' " . $db -> escape ( $search_gender ) . " ' " ; // Cannot use natural_search as looking for %man% also includes woman
}
2020-01-30 01:48:28 +01:00
if ( is_numeric ( $search_employee ) && $search_employee >= 0 ) {
2016-04-10 01:00:27 +02:00
$sql .= ' AND u.employee = ' . ( int ) $search_employee ;
}
2021-02-26 13:18:40 +01:00
if ( $search_accountancy_code != '' ) {
$sql .= natural_search ( " u.accountancy_code " , $search_accountancy_code );
}
if ( $search_phonepro != '' ) {
$sql .= natural_search ( " u.office_phone " , $search_phonepro );
}
if ( $search_phonemobile != '' ) {
$sql .= natural_search ( " u.user_mobile " , $search_phonemobile );
}
if ( $search_email != '' ) {
$sql .= natural_search ( " u.email " , $search_email );
}
if ( $search_api_key != '' ) {
$sql .= natural_search ( " u.api_key " , $search_api_key );
}
if ( $search_statut != '' && $search_statut >= 0 ) {
2021-03-22 11:30:18 +01:00
$sql .= " AND u.statut IN ( " . $db -> sanitize ( $search_statut ) . " ) " ;
2021-02-26 13:18:40 +01:00
}
if ( $sall ) {
$sql .= natural_search ( array_keys ( $fieldstosearchall ), $sall );
}
if ( $catid > 0 ) {
$sql .= " AND cu.fk_categorie = " . (( int ) $catid );
}
if ( $catid == - 2 ) {
$sql .= " AND cu.fk_categorie IS NULL " ;
}
if ( $search_categ > 0 ) {
2021-05-06 11:18:35 +02:00
$sql .= " AND cu.fk_categorie = " . (( int ) $search_categ );
2021-02-26 13:18:40 +01:00
}
if ( $search_categ == - 2 ) {
$sql .= " AND cu.fk_categorie IS NULL " ;
}
2021-05-06 22:11:41 +02:00
if ( $search_warehouse > 0 ) {
2021-06-09 15:36:47 +02:00
$sql .= " AND u.fk_warehouse = " . (( int ) $search_warehouse );
2021-05-06 22:11:41 +02:00
}
2021-02-26 13:18:40 +01:00
if ( $mode == 'employee' && empty ( $user -> rights -> salaries -> readall )) {
2021-05-06 11:25:46 +02:00
$sql .= " AND u.rowid IN ( " . $db -> sanitize ( join ( ',' , $childids )) . " ) " ;
2021-02-26 13:18:40 +01:00
}
2015-10-25 18:15:37 +01:00
// Add where from extra fields
2017-11-27 15:24:29 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_sql.tpl.php' ;
2015-10-25 18:15:37 +01:00
// Add where from hooks
2020-01-30 01:48:28 +01:00
$parameters = array ();
2020-10-01 16:21:07 +02:00
$reshook = $hookmanager -> executeHooks ( 'printFieldListWhere' , $parameters , $object ); // Note that $action and $object may have been modified by hook
2020-01-30 01:48:28 +01:00
$sql .= $hookmanager -> resPrint ;
$sql .= $db -> order ( $sortfield , $sortorder );
2002-05-06 21:10:48 +02:00
2020-10-01 16:21:07 +02:00
// Count total nb of records
$nbtotalofrecords = '' ;
2021-02-26 13:18:40 +01:00
if ( empty ( $conf -> global -> MAIN_DISABLE_FULL_SCANLIST )) {
2020-10-01 16:21:07 +02:00
$resql = $db -> query ( $sql );
$nbtotalofrecords = $db -> num_rows ( $resql );
2021-02-26 13:18:40 +01:00
if (( $page * $limit ) > $nbtotalofrecords ) { // if total of record found is smaller than page * limit, goto and load page 0
2020-10-01 16:21:07 +02:00
$page = 0 ;
$offset = 0 ;
}
2016-07-06 10:28:34 +02:00
}
2020-10-01 16:21:07 +02:00
// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set.
2021-02-26 13:18:40 +01:00
if ( is_numeric ( $nbtotalofrecords ) && ( $limit > $nbtotalofrecords || empty ( $limit ))) {
2020-10-01 16:21:07 +02:00
$num = $nbtotalofrecords ;
} else {
2021-02-26 13:18:40 +01:00
if ( $limit ) {
$sql .= $db -> plimit ( $limit + 1 , $offset );
}
2016-07-06 10:28:34 +02:00
2020-10-01 16:21:07 +02:00
$resql = $db -> query ( $sql );
2021-02-26 13:18:40 +01:00
if ( ! $resql ) {
2020-10-01 16:21:07 +02:00
dol_print_error ( $db );
exit ;
}
2016-09-12 21:32:27 +02:00
2020-10-01 16:21:07 +02:00
$num = $db -> num_rows ( $resql );
2016-11-02 12:48:50 +01:00
}
2020-10-01 16:21:07 +02:00
// Direct jump if only one record found
2021-02-26 13:18:40 +01:00
if ( $num == 1 && ! empty ( $conf -> global -> MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE ) && $search_all && ! $page ) {
2017-10-13 13:28:26 +02:00
$obj = $db -> fetch_object ( $resql );
$id = $obj -> rowid ;
header ( " Location: " . DOL_URL_ROOT . '/user/card.php?id=' . $id );
exit ;
2016-11-02 12:48:50 +01:00
}
2020-10-01 16:21:07 +02:00
// Output page
// --------------------------------------------------------------------
llxHeader ( '' , $langs -> trans ( " ListOfUsers " ), $help_url );
2016-11-02 12:48:50 +01:00
2019-11-13 19:35:39 +01:00
$param = '' ;
2021-02-26 13:18:40 +01:00
if ( ! empty ( $contextpage ) && $contextpage != $_SERVER [ " PHP_SELF " ]) {
$param .= '&contextpage=' . urlencode ( $contextpage );
}
if ( $limit > 0 && $limit != $conf -> liste_limit ) {
$param .= '&limit=' . urlencode ( $limit );
}
if ( $sall != '' ) {
$param .= '&sall=' . urlencode ( $sall );
}
if ( $search_user != '' ) {
$param .= " &search_user= " . urlencode ( $search_user );
}
if ( $search_login != '' ) {
$param .= " &search_login= " . urlencode ( $search_login );
}
if ( $search_lastname != '' ) {
$param .= " &search_lastname= " . urlencode ( $search_lastname );
}
if ( $search_firstname != '' ) {
$param .= " &search_firstname= " . urlencode ( $search_firstname );
}
if ( $search_gender != '' ) {
$param .= " &search_gender= " . urlencode ( $search_gender );
}
if ( $search_employee != '' ) {
$param .= " &search_employee= " . urlencode ( $search_employee );
}
if ( $search_accountancy_code != '' ) {
$param .= " &search_accountancy_code= " . urlencode ( $search_accountancy_code );
}
if ( $search_phonepro != '' ) {
$param .= " &search_phonepro= " . urlencode ( $search_phonepro );
}
if ( $search_phonemobile != '' ) {
$param .= " &search_phonemobile= " . urlencode ( $search_phonemobile );
}
if ( $search_email != '' ) {
$param .= " &search_email= " . urlencode ( $search_email );
}
if ( $search_api_key != '' ) {
$param .= " &search_api_key= " . urlencode ( $search_api_key );
}
if ( $search_supervisor > 0 ) {
$param .= " &search_supervisor= " . urlencode ( $search_supervisor );
}
if ( $search_statut != '' ) {
$param .= " &search_statut= " . urlencode ( $search_statut );
}
if ( $optioncss != '' ) {
$param .= '&optioncss=' . urlencode ( $optioncss );
}
if ( $mode != '' ) {
$param .= '&mode=' . urlencode ( $mode );
}
if ( $search_categ > 0 ) {
2021-05-06 22:11:41 +02:00
$param .= '&search_categ=' . urlencode ( $search_categ );
}
if ( $search_warehouse > 0 ) {
$param .= '&search_warehouse=' . urlencode ( $search_warehouse );
2021-02-26 13:18:40 +01:00
}
2016-11-02 12:48:50 +01:00
// Add $param from extra fields
2017-11-27 15:24:29 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_param.tpl.php' ;
2016-11-02 12:48:50 +01:00
2020-10-01 16:21:07 +02:00
// List of mass actions available
$arrayofmassactions = array ();
2021-02-26 13:18:40 +01:00
if ( $permissiontoadd ) {
2021-04-14 12:28:01 +02:00
$arrayofmassactions [ 'disable' ] = img_picto ( '' , 'close_title' , 'class="pictofixedwidth"' ) . $langs -> trans ( " DisableUser " );
2021-02-26 13:18:40 +01:00
}
if ( $permissiontoadd ) {
2021-04-14 12:28:01 +02:00
$arrayofmassactions [ 'reactivate' ] = img_picto ( '' , 'check' , 'class="pictofixedwidth"' ) . $langs -> trans ( " Reactivate " );
2021-02-26 13:18:40 +01:00
}
if ( $permissiontoadd ) {
2021-04-14 12:33:53 +02:00
$arrayofmassactions [ 'preaffecttag' ] = img_picto ( '' , 'category' , 'class="pictofixedwidth"' ) . $langs -> trans ( " AffectTag " );
2021-02-26 13:18:40 +01:00
}
2022-04-29 13:10:28 +02:00
//if ($permissiontodelete) $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
2016-11-02 12:48:50 +01:00
2021-02-26 13:18:40 +01:00
if ( GETPOST ( 'nomassaction' , 'int' ) || in_array ( $massaction , array ( 'presend' , 'predelete' , 'preaffecttag' ))) {
$arrayofmassactions = array ();
}
2020-10-01 16:21:07 +02:00
$massactionbutton = $form -> selectMassAction ( '' , $arrayofmassactions );
2018-04-07 16:17:40 +02:00
2016-11-02 12:48:50 +01:00
print '<form method="POST" id="searchFormList" action="' . $_SERVER [ " PHP_SELF " ] . '">' . " \n " ;
2021-02-26 13:18:40 +01:00
if ( $optioncss != '' ) {
print '<input type="hidden" name="optioncss" value="' . $optioncss . '">' ;
}
2019-12-01 10:20:11 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2016-11-02 12:48:50 +01:00
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">' ;
print '<input type="hidden" name="sortfield" value="' . $sortfield . '">' ;
print '<input type="hidden" name="sortorder" value="' . $sortorder . '">' ;
print '<input type="hidden" name="mode" value="' . $mode . '">' ;
print '<input type="hidden" name="contextpage" value="' . $contextpage . '">' ;
2020-10-01 16:21:07 +02:00
$url = DOL_URL_ROOT . '/user/card.php?action=create' . ( $mode == 'employee' ? '&employee=1' : '' ) . '&leftmenu=' ;
2021-02-26 13:18:40 +01:00
if ( ! empty ( $socid )) {
2021-05-20 14:25:54 +02:00
$url .= '&socid=' . urlencode ( $socid );
2021-02-26 13:18:40 +01:00
}
2020-10-01 16:21:07 +02:00
$newcardbutton = dolGetButtonTitle ( $langs -> trans ( 'NewUser' ), '' , 'fa fa-plus-circle' , $url , '' , $permissiontoadd );
2020-10-01 16:27:17 +02:00
$moreparam = array ( 'morecss' => 'btnTitleSelected' );
2021-05-18 20:13:26 +02:00
$morehtmlright = dolGetButtonTitle ( $langs -> trans ( " List " ), '' , 'fa fa-list paddingleft imgforviewmode' , DOL_URL_ROOT . '/user/list.php' . (( $search_statut != '' && $search_statut >= 0 ) ? '?search_statut=' . $search_statut : '' ), '' , 1 , $moreparam );
2020-10-01 16:27:17 +02:00
$moreparam = array ( 'morecss' => 'marginleftonly' );
$morehtmlright .= dolGetButtonTitle ( $langs -> trans ( " HierarchicView " ), '' , 'fa fa-stream paddingleft imgforviewmode' , DOL_URL_ROOT . '/user/hierarchy.php' . (( $search_statut != '' && $search_statut >= 0 ) ? '?search_statut=' . $search_statut : '' ), '' , 1 , $moreparam );
2019-04-15 00:21:58 +02:00
2020-10-01 16:21:07 +02:00
print_barre_liste ( $text , $page , $_SERVER [ " PHP_SELF " ], $param , $sortfield , $sortorder , $massactionbutton , $num , $nbtotalofrecords , 'user' , 0 , $morehtmlright . ' ' . $newcardbutton , '' , $limit , 0 , 0 , 1 );
// Add code for pre mass action (confirmation or email presend form)
$topicmail = " SendUserRef " ;
$modelmail = " user " ;
$objecttmp = new User ( $db );
$trackid = 'use' . $object -> id ;
include DOL_DOCUMENT_ROOT . '/core/tpl/massactions_pre.tpl.php' ;
2016-11-02 12:48:50 +01:00
2021-02-26 13:18:40 +01:00
if ( ! empty ( $catid )) {
2020-10-07 15:01:28 +02:00
print " <div id='ways'> " ;
$c = new Categorie ( $db );
$ways = $c -> print_all_ways ( ' > ' , 'user/list.php' );
print " > " . $ways [ 0 ] . " <br> \n " ;
print " </div><br> " ;
2018-10-09 01:01:58 +02:00
}
2021-02-26 13:18:40 +01:00
if ( $search_all ) {
foreach ( $fieldstosearchall as $key => $val ) {
$fieldstosearchall [ $key ] = $langs -> trans ( $val );
}
2020-10-01 16:21:07 +02:00
print '<div class="divsearchfieldfilter">' . $langs -> trans ( " FilterOnInto " , $search_all ) . join ( ', ' , $fieldstosearchall ) . '</div>' ;
2016-11-02 12:48:50 +01:00
}
2019-11-13 19:35:39 +01:00
$moreforfilter = '' ;
2020-10-01 16:21:07 +02:00
/* $moreforfilter .= '<div class="divsearchfield">' ;
$moreforfilter .= $langs -> trans ( 'MyFilter' ) . ': <input type="text" name="search_myfield" value="' . dol_escape_htmltag ( $search_myfield ) . '">' ;
$moreforfilter .= '</div>' ; */
2016-11-02 12:48:50 +01:00
2018-10-09 01:01:58 +02:00
// Filter on categories
2021-02-26 13:18:40 +01:00
if ( ! empty ( $conf -> categorie -> enabled ) && $user -> rights -> categorie -> lire ) {
2020-10-07 15:01:28 +02:00
$moreforfilter .= '<div class="divsearchfield">' ;
2021-05-06 22:11:41 +02:00
$tmptitle = $langs -> trans ( 'Category' );
$moreforfilter .= img_picto ( $langs -> trans ( " Category " ), 'category' , 'class="pictofixedwidth"' ) . $formother -> select_categories ( Categorie :: TYPE_USER , $search_categ , 'search_categ' , 1 , $tmptitle );
$moreforfilter .= '</div>' ;
}
2021-05-06 22:14:45 +02:00
// Filter on warehouse
2021-05-06 22:11:41 +02:00
if ( ! empty ( $conf -> stock -> enabled ) && ! empty ( $conf -> global -> MAIN_DEFAULT_WAREHOUSE_USER )) {
require_once DOL_DOCUMENT_ROOT . '/product/class/html.formproduct.class.php' ;
$formproduct = new FormProduct ( $db );
$moreforfilter .= '<div class="divsearchfield">' ;
$tmptitle = $langs -> trans ( 'Warehouse' );
$moreforfilter .= img_picto ( $tmptitle , 'stock' , 'class="pictofixedwidth"' ) . $formproduct -> selectWarehouses ( $search_warehouse , 'search_warehouse' , '' , $tmptitle , 0 , 0 , $tmptitle );
2020-10-07 15:01:28 +02:00
$moreforfilter .= '</div>' ;
2018-10-09 01:01:58 +02:00
}
2019-11-13 19:35:39 +01:00
$parameters = array ();
2020-10-01 16:21:07 +02:00
$reshook = $hookmanager -> executeHooks ( 'printFieldPreListTitle' , $parameters , $object ); // Note that $action and $object may have been modified by hook
2021-02-26 13:18:40 +01:00
if ( empty ( $reshook )) {
$moreforfilter .= $hookmanager -> resPrint ;
} else {
$moreforfilter = $hookmanager -> resPrint ;
}
2018-10-09 01:01:58 +02:00
2021-02-26 13:18:40 +01:00
if ( ! empty ( $moreforfilter )) {
2020-10-07 15:01:28 +02:00
print '<div class="liste_titre liste_titre_bydiv centpercent">' ;
print $moreforfilter ;
print '</div>' ;
2018-10-09 01:01:58 +02:00
}
2019-11-13 19:35:39 +01:00
$varpage = empty ( $contextpage ) ? $_SERVER [ " PHP_SELF " ] : $contextpage ;
$selectedfields = $form -> multiSelectArrayWithCheckbox ( 'selectedfields' , $arrayfields , $varpage ); // This also change content of $arrayfields
2020-10-01 16:21:07 +02:00
$selectedfields .= ( count ( $arrayofmassactions ) ? $form -> showCheckAddButtons ( 'checkforselect' , 1 ) : '' );
2016-11-02 12:48:50 +01:00
2020-10-01 16:21:07 +02:00
print '<div class="div-table-responsive">' ; // You can use div-table-responsive-no-min if you dont need reserved height for your table
print '<table class="tagtable nobottomiftotal liste' . ( $moreforfilter ? " listwithfilterbefore " : " " ) . '">' . " \n " ;
2016-11-27 13:49:46 +01:00
2020-10-01 16:21:07 +02:00
// Fields title search
// --------------------------------------------------------------------
2017-03-30 16:00:53 +02:00
print '<tr class="liste_titre_filter">' ;
2021-02-26 13:18:40 +01:00
if ( ! empty ( $arrayfields [ 'u.login' ][ 'checked' ])) {
2019-07-18 14:08:15 +02:00
print '<td class="liste_titre"><input type="text" name="search_login" class="maxwidth50" value="' . $search_login . '"></td>' ;
2016-11-02 12:48:50 +01:00
}
2021-02-26 13:18:40 +01:00
if ( ! empty ( $arrayfields [ 'u.lastname' ][ 'checked' ])) {
2019-07-18 14:08:15 +02:00
print '<td class="liste_titre"><input type="text" name="search_lastname" class="maxwidth50" value="' . $search_lastname . '"></td>' ;
2016-11-02 12:48:50 +01:00
}
2021-02-26 13:18:40 +01:00
if ( ! empty ( $arrayfields [ 'u.firstname' ][ 'checked' ])) {
2019-07-18 14:08:15 +02:00
print '<td class="liste_titre"><input type="text" name="search_firstname" class="maxwidth50" value="' . $search_firstname . '"></td>' ;
2016-11-02 12:48:50 +01:00
}
2021-02-26 13:18:40 +01:00
if ( ! empty ( $arrayfields [ 'u.gender' ][ 'checked' ])) {
2017-10-13 13:28:26 +02:00
print '<td class="liste_titre">' ;
2020-09-15 10:57:48 +02:00
$arraygender = array ( 'man' => $langs -> trans ( " Genderman " ), 'woman' => $langs -> trans ( " Genderwoman " ), 'other' => $langs -> trans ( " Genderother " ));
2017-10-13 13:28:26 +02:00
print $form -> selectarray ( 'search_gender' , $arraygender , $search_gender , 1 );
print '</td>' ;
2016-11-02 12:48:50 +01:00
}
2021-02-26 13:18:40 +01:00
if ( ! empty ( $arrayfields [ 'u.employee' ][ 'checked' ])) {
2017-10-13 13:28:26 +02:00
print '<td class="liste_titre">' ;
print $form -> selectyesno ( 'search_employee' , $search_employee , 1 , false , 1 );
print '</td>' ;
2016-11-02 12:48:50 +01:00
}
2020-12-03 00:40:41 +01:00
// Supervisor
2021-02-26 13:18:40 +01:00
if ( ! empty ( $arrayfields [ 'u.fk_user' ][ 'checked' ])) {
print '<td class="liste_titre">' ;
print $form -> select_dolusers ( $search_supervisor , 'search_supervisor' , 1 , array (), 0 , '' , 0 , 0 , 0 , 0 , '' , 0 , '' , 'maxwidth200' );
print '</td>' ;
}
if ( ! empty ( $arrayfields [ 'u.accountancy_code' ][ 'checked' ])) {
2019-07-18 14:08:15 +02:00
print '<td class="liste_titre"><input type="text" name="search_accountancy_code" class="maxwidth50" value="' . $search_accountancy_code . '"></td>' ;
2016-11-02 12:48:50 +01:00
}
2021-02-26 13:18:40 +01:00
if ( ! empty ( $arrayfields [ 'u.office_phone' ][ 'checked' ])) {
2021-06-15 16:18:15 +02:00
print '<td class="liste_titre"><input type="text" name="search_phonepro" class="maxwidth50" value="' . $search_phonepro . '"></td>' ;
2021-01-13 18:52:27 +01:00
}
2021-02-26 13:18:40 +01:00
if ( ! empty ( $arrayfields [ 'u.user_mobile' ][ 'checked' ])) {
2021-06-15 16:18:15 +02:00
print '<td class="liste_titre"><input type="text" name="search_phonemobile" class="maxwidth50" value="' . $search_phonemobile . '"></td>' ;
2021-01-13 18:52:27 +01:00
}
2021-02-26 13:18:40 +01:00
if ( ! empty ( $arrayfields [ 'u.email' ][ 'checked' ])) {
2019-07-18 14:08:15 +02:00
print '<td class="liste_titre"><input type="text" name="search_email" class="maxwidth75" value="' . $search_email . '"></td>' ;
}
2021-02-26 13:18:40 +01:00
if ( ! empty ( $arrayfields [ 'u.api_key' ][ 'checked' ])) {
2019-07-18 14:08:15 +02:00
print '<td class="liste_titre"><input type="text" name="search_api_key" class="maxwidth50" value="' . $search_api_key . '"></td>' ;
2016-11-02 12:48:50 +01:00
}
2021-02-26 13:18:40 +01:00
if ( ! empty ( $arrayfields [ 'u.fk_soc' ][ 'checked' ])) {
2019-07-18 14:08:15 +02:00
print '<td class="liste_titre"><input type="text" name="search_thirdparty" class="maxwidth75" value="' . $search_thirdparty . '"></td>' ;
2016-11-02 12:48:50 +01:00
}
2021-02-26 13:18:40 +01:00
if ( ! empty ( $arrayfields [ 'u.entity' ][ 'checked' ])) {
2017-10-13 13:28:26 +02:00
print '<td class="liste_titre"></td>' ;
2016-11-02 12:48:50 +01:00
}
2021-02-26 13:18:40 +01:00
if ( ! empty ( $arrayfields [ 'u.salary' ][ 'checked' ])) {
print '<td class="liste_titre"></td>' ;
2016-11-02 12:48:50 +01:00
}
2021-02-26 13:18:40 +01:00
if ( ! empty ( $arrayfields [ 'u.datelastlogin' ][ 'checked' ])) {
2017-10-13 13:28:26 +02:00
print '<td class="liste_titre"></td>' ;
2016-11-02 12:48:50 +01:00
}
2021-02-26 13:18:40 +01:00
if ( ! empty ( $arrayfields [ 'u.datepreviouslogin' ][ 'checked' ])) {
2017-10-13 13:28:26 +02:00
print '<td class="liste_titre"></td>' ;
2016-11-02 12:48:50 +01:00
}
// Extra fields
2017-11-27 15:24:29 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_input.tpl.php' ;
2016-11-02 12:48:50 +01:00
// Fields from hook
2019-11-13 19:35:39 +01:00
$parameters = array ( 'arrayfields' => $arrayfields );
2020-10-01 16:21:07 +02:00
$reshook = $hookmanager -> executeHooks ( 'printFieldListOption' , $parameters , $object ); // Note that $action and $object may have been modified by hook
2016-11-02 12:48:50 +01:00
print $hookmanager -> resPrint ;
2021-02-26 13:18:40 +01:00
if ( ! empty ( $arrayfields [ 'u.datec' ][ 'checked' ])) {
2017-10-13 13:28:26 +02:00
// Date creation
print '<td class="liste_titre">' ;
print '</td>' ;
2016-11-02 12:48:50 +01:00
}
2021-02-26 13:18:40 +01:00
if ( ! empty ( $arrayfields [ 'u.tms' ][ 'checked' ])) {
2017-10-13 13:28:26 +02:00
// Date modification
print '<td class="liste_titre">' ;
print '</td>' ;
2016-11-02 12:48:50 +01:00
}
2021-02-26 13:18:40 +01:00
if ( ! empty ( $arrayfields [ 'u.statut' ][ 'checked' ])) {
2017-10-13 13:28:26 +02:00
// Status
2019-02-16 10:29:15 +01:00
print '<td class="liste_titre center">' ;
2021-12-12 23:47:40 +01:00
print $form -> selectarray ( 'search_statut' , array ( '-1' => '' , '0' => $langs -> trans ( 'Disabled' ), '1' => $langs -> trans ( 'Enabled' )), $search_statut , 0 , 0 , 0 , '' , 0 , 0 , 0 , '' , 'minwidth75imp' );
2017-10-13 13:28:26 +02:00
print '</td>' ;
2016-11-02 12:48:50 +01:00
}
// Action column
2019-05-19 13:51:47 +02:00
print '<td class="liste_titre maxwidthsearch">' ;
2020-10-01 16:21:07 +02:00
$searchpicto = $form -> showFilterButtons ();
2017-05-14 21:20:35 +02:00
print $searchpicto ;
2016-11-02 12:48:50 +01:00
print '</td>' ;
2020-10-01 16:21:07 +02:00
print '</tr>' . " \n " ;
2016-11-02 12:48:50 +01:00
2017-03-30 16:00:53 +02:00
print '<tr class="liste_titre">' ;
2021-02-26 13:18:40 +01:00
if ( ! empty ( $arrayfields [ 'u.login' ][ 'checked' ])) {
print_liste_field_titre ( " Login " , $_SERVER [ 'PHP_SELF' ], " u.login " , $param , " " , " " , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 'u.lastname' ][ 'checked' ])) {
print_liste_field_titre ( " Lastname " , $_SERVER [ 'PHP_SELF' ], " u.lastname " , $param , " " , " " , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 'u.firstname' ][ 'checked' ])) {
print_liste_field_titre ( " FirstName " , $_SERVER [ 'PHP_SELF' ], " u.firstname " , $param , " " , " " , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 'u.gender' ][ 'checked' ])) {
print_liste_field_titre ( " Gender " , $_SERVER [ 'PHP_SELF' ], " u.gender " , $param , " " , " " , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 'u.employee' ][ 'checked' ])) {
2021-04-18 16:56:55 +02:00
print_liste_field_titre ( " Employee " , $_SERVER [ 'PHP_SELF' ], " u.employee " , $param , " " , " " , $sortfield , $sortorder , 'center ' );
2021-02-26 13:18:40 +01:00
}
if ( ! empty ( $arrayfields [ 'u.fk_user' ][ 'checked' ])) {
print_liste_field_titre ( " HierarchicalResponsible " , $_SERVER [ 'PHP_SELF' ], " u.fk_user " , $param , " " , " " , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 'u.accountancy_code' ][ 'checked' ])) {
print_liste_field_titre ( " AccountancyCode " , $_SERVER [ 'PHP_SELF' ], " u.accountancy_code " , $param , " " , " " , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 'u.office_phone' ][ 'checked' ])) {
print_liste_field_titre ( " PhonePro " , $_SERVER [ 'PHP_SELF' ], " u.office_phone " , $param , " " , " " , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 'u.user_mobile' ][ 'checked' ])) {
print_liste_field_titre ( " PhoneMobile " , $_SERVER [ 'PHP_SELF' ], " u.user_mobile " , $param , " " , " " , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 'u.email' ][ 'checked' ])) {
print_liste_field_titre ( " EMail " , $_SERVER [ 'PHP_SELF' ], " u.email " , $param , " " , " " , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 'u.api_key' ][ 'checked' ])) {
print_liste_field_titre ( " ApiKey " , $_SERVER [ 'PHP_SELF' ], " u.api_key " , $param , " " , " " , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 'u.fk_soc' ][ 'checked' ])) {
print_liste_field_titre ( " Company " , $_SERVER [ 'PHP_SELF' ], " u.fk_soc " , $param , " " , " " , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 'u.entity' ][ 'checked' ])) {
print_liste_field_titre ( " Entity " , $_SERVER [ 'PHP_SELF' ], " u.entity " , $param , " " , " " , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 'u.salary' ][ 'checked' ])) {
print_liste_field_titre ( " Salary " , $_SERVER [ 'PHP_SELF' ], " u.salary " , $param , " " , " " , $sortfield , $sortorder , 'right ' );
}
if ( ! empty ( $arrayfields [ 'u.datelastlogin' ][ 'checked' ])) {
print_liste_field_titre ( " LastConnexion " , $_SERVER [ 'PHP_SELF' ], " u.datelastlogin " , $param , " " , '' , $sortfield , $sortorder , 'center ' );
}
if ( ! empty ( $arrayfields [ 'u.datepreviouslogin' ][ 'checked' ])) {
print_liste_field_titre ( " PreviousConnexion " , $_SERVER [ 'PHP_SELF' ], " u.datepreviouslogin " , $param , " " , '' , $sortfield , $sortorder , 'center ' );
}
2017-03-30 16:00:53 +02:00
// Extra fields
2017-11-27 15:24:29 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_title.tpl.php' ;
2017-03-30 16:00:53 +02:00
// Hook fields
2020-01-30 01:48:28 +01:00
$parameters = array ( 'arrayfields' => $arrayfields , 'param' => $param , 'sortfield' => $sortfield , 'sortorder' => $sortorder );
2020-10-01 16:21:07 +02:00
$reshook = $hookmanager -> executeHooks ( 'printFieldListTitle' , $parameters , $object ); // Note that $action and $object may have been modified by hook
2017-03-30 16:00:53 +02:00
print $hookmanager -> resPrint ;
2021-02-26 13:18:40 +01:00
if ( ! empty ( $arrayfields [ 'u.datec' ][ 'checked' ])) {
print_liste_field_titre ( " DateCreationShort " , $_SERVER [ " PHP_SELF " ], " u.datec " , " " , $param , '' , $sortfield , $sortorder , 'center nowrap ' );
}
if ( ! empty ( $arrayfields [ 'u.tms' ][ 'checked' ])) {
print_liste_field_titre ( " DateModificationShort " , $_SERVER [ " PHP_SELF " ], " u.tms " , " " , $param , '' , $sortfield , $sortorder , 'center nowrap ' );
}
if ( ! empty ( $arrayfields [ 'u.statut' ][ 'checked' ])) {
print_liste_field_titre ( " Status " , $_SERVER [ " PHP_SELF " ], " u.statut " , " " , $param , '' , $sortfield , $sortorder , 'center ' );
}
2020-10-01 16:21:07 +02:00
// Action column
print getTitleFieldOfList ( $selectedfields , 0 , $_SERVER [ " PHP_SELF " ], '' , '' , '' , '' , $sortfield , $sortorder , 'center maxwidthsearch ' ) . " \n " ;
print '</tr>' . " \n " ;
2017-03-30 16:00:53 +02:00
2020-10-01 16:21:07 +02:00
// Detect if we need a fetch on each output line
$needToFetchEachLine = 0 ;
2021-05-18 20:13:26 +02:00
if ( key_exists ( 'computed' , $extrafields -> attributes [ $object -> table_element ]) && is_array ( $extrafields -> attributes [ $object -> table_element ][ 'computed' ]) && count ( $extrafields -> attributes [ $object -> table_element ][ 'computed' ]) > 0 ) {
2021-02-26 13:18:40 +01:00
foreach ( $extrafields -> attributes [ $object -> table_element ][ 'computed' ] as $key => $val ) {
if ( preg_match ( '/\$object/' , $val )) {
$needToFetchEachLine ++ ; // There is at least one compute field that use $object
}
2020-10-01 16:21:07 +02:00
}
}
2016-11-02 12:48:50 +01:00
2020-10-01 16:21:07 +02:00
// Loop on record
// --------------------------------------------------------------------
2016-11-02 12:48:50 +01:00
$i = 0 ;
2020-01-30 01:48:28 +01:00
$totalarray = array ();
2021-05-18 20:13:26 +02:00
$totalarray [ 'nbfield' ] = 0 ;
2020-12-23 23:44:38 +01:00
$arrayofselected = is_array ( $toselect ) ? $toselect : array ();
2021-02-26 13:18:40 +01:00
while ( $i < ( $limit ? min ( $num , $limit ) : $num )) {
2020-10-01 16:21:07 +02:00
$obj = $db -> fetch_object ( $resql );
2021-02-26 13:18:40 +01:00
if ( empty ( $obj )) {
break ; // Should not happen
}
2020-10-01 16:21:07 +02:00
2021-05-20 14:28:43 +02:00
if ( empty ( $obj -> country_code )) $obj -> country_code = '' ; // TODO Add join in select with country table to get country_code
2020-10-01 16:21:07 +02:00
// Store properties in $object
$object -> setVarsFromFetchObj ( $obj );
2016-11-02 12:48:50 +01:00
2020-01-30 01:48:28 +01:00
$userstatic -> id = $obj -> rowid ;
2019-11-04 20:16:34 +01:00
$userstatic -> admin = $obj -> admin ;
2021-05-20 14:28:43 +02:00
$userstatic -> ref = $obj -> rowid ;
2020-01-30 01:48:28 +01:00
$userstatic -> login = $obj -> login ;
$userstatic -> statut = $obj -> statut ;
2021-01-13 18:52:27 +01:00
$userstatic -> office_phone = $obj -> office_phone ;
$userstatic -> user_mobile = $obj -> user_mobile ;
2020-01-30 01:48:28 +01:00
$userstatic -> email = $obj -> email ;
$userstatic -> gender = $obj -> gender ;
$userstatic -> socid = $obj -> fk_soc ;
$userstatic -> firstname = $obj -> firstname ;
$userstatic -> lastname = $obj -> lastname ;
$userstatic -> employee = $obj -> employee ;
$userstatic -> photo = $obj -> photo ;
$li = $userstatic -> getNomUrl ( - 1 , '' , 0 , 0 , 24 , 1 , 'login' , '' , 1 );
2014-05-30 12:32:19 +02:00
2021-06-15 14:18:09 +02:00
$canreadhrmdata = 0 ;
if (( ! empty ( $conf -> salaries -> enabled ) && ! empty ( $user -> rights -> salaries -> read ) && in_array ( $obj -> rowid , $childids ))
|| ( ! empty ( $conf -> salaries -> enabled ) && ! empty ( $user -> rights -> salaries -> readall ))
|| ( ! empty ( $conf -> hrm -> enabled ) && ! empty ( $user -> rights -> hrm -> employee -> read ))) {
$canreadhrmdata = 1 ;
}
$canreadsecretapi = 0 ;
2021-08-31 20:21:20 +02:00
if ( $user -> id == $obj -> rowid || ! empty ( $user -> admin )) { // Current user or admin
2021-06-15 14:18:09 +02:00
$canreadsecretapi = 1 ;
}
2020-10-01 16:21:07 +02:00
print '<tr class="oddeven">' ;
2021-04-18 16:56:55 +02:00
2021-06-15 14:18:09 +02:00
// Login
2021-02-26 13:18:40 +01:00
if ( ! empty ( $arrayfields [ 'u.login' ][ 'checked' ])) {
2021-06-14 15:05:54 +02:00
print '<td class="nowraponall tdoverflowmax150">' ;
2016-11-02 12:48:50 +01:00
print $li ;
2021-02-26 13:18:40 +01:00
if ( ! empty ( $conf -> multicompany -> enabled ) && $obj -> admin && ! $obj -> entity ) {
print img_picto ( $langs -> trans ( " SuperAdministrator " ), 'redstar' , 'class="valignmiddle paddingleft"' );
} elseif ( $obj -> admin ) {
2017-10-13 13:28:26 +02:00
print img_picto ( $langs -> trans ( " Administrator " ), 'star' , 'class="valignmiddle paddingleft"' );
}
print '</td>' ;
2021-02-26 13:18:40 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2016-11-02 12:48:50 +01:00
}
2021-02-26 13:18:40 +01:00
if ( ! empty ( $arrayfields [ 'u.lastname' ][ 'checked' ])) {
2021-04-18 16:56:55 +02:00
print '<td class="tdoverflowmax150" title="' . dol_escape_htmltag ( $obj -> lastname ) . '">' . dol_escape_htmltag ( $obj -> lastname ) . '</td>' ;
2021-02-26 13:18:40 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2016-11-02 12:48:50 +01:00
}
2021-02-26 13:18:40 +01:00
if ( ! empty ( $arrayfields [ 'u.firstname' ][ 'checked' ])) {
2021-04-18 16:56:55 +02:00
print '<td class="tdoverflowmax150" title="' . dol_escape_htmltag ( $obj -> lastname ) . '">' . dol_escape_htmltag ( $obj -> firstname ) . '</td>' ;
2021-02-26 13:18:40 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2016-11-02 12:48:50 +01:00
}
2021-02-26 13:18:40 +01:00
if ( ! empty ( $arrayfields [ 'u.gender' ][ 'checked' ])) {
2020-10-07 15:01:28 +02:00
print '<td>' ;
2021-02-26 13:18:40 +01:00
if ( $obj -> gender ) {
print $langs -> trans ( " Gender " . $obj -> gender );
}
2020-10-07 15:01:28 +02:00
print '</td>' ;
2021-02-26 13:18:40 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2016-11-02 12:48:50 +01:00
}
2021-06-15 14:18:09 +02:00
// Employee yes/no
2021-02-26 13:18:40 +01:00
if ( ! empty ( $arrayfields [ 'u.employee' ][ 'checked' ])) {
2021-04-18 16:56:55 +02:00
print '<td class="center">' . yn ( $obj -> employee ) . '</td>' ;
2021-02-26 13:18:40 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2016-11-02 12:48:50 +01:00
}
2020-12-03 00:40:41 +01:00
// Supervisor
2021-02-26 13:18:40 +01:00
if ( ! empty ( $arrayfields [ 'u.fk_user' ][ 'checked' ])) {
// Resp
print '<td class="nowrap">' ;
if ( $obj -> login2 ) {
$user2 -> id = $obj -> id2 ;
$user2 -> login = $obj -> login2 ;
$user2 -> lastname = $obj -> lastname2 ;
$user2 -> firstname = $obj -> firstname2 ;
$user2 -> gender = $obj -> gender2 ;
$user2 -> photo = $obj -> photo2 ;
$user2 -> admin = $obj -> admin2 ;
2021-01-13 18:52:27 +01:00
$user2 -> office_phone = $obj -> office_phone ;
$user2 -> user_mobile = $obj -> user_mobile ;
2021-02-26 13:18:40 +01:00
$user2 -> email = $obj -> email2 ;
$user2 -> socid = $obj -> fk_soc2 ;
$user2 -> statut = $obj -> statut2 ;
print $user2 -> getNomUrl ( - 1 , '' , 0 , 0 , 24 , 0 , '' , '' , 1 );
if ( ! empty ( $conf -> multicompany -> enabled ) && $obj -> admin2 && ! $obj -> entity2 ) {
print img_picto ( $langs -> trans ( " SuperAdministrator " ), 'redstar' , 'class="valignmiddle paddingleft"' );
} elseif ( $obj -> admin2 ) {
print img_picto ( $langs -> trans ( " Administrator " ), 'star' , 'class="valignmiddle paddingleft"' );
}
}
print '</td>' ;
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
}
if ( ! empty ( $arrayfields [ 'u.accountancy_code' ][ 'checked' ])) {
2020-10-07 15:01:28 +02:00
print '<td>' . $obj -> accountancy_code . '</td>' ;
2021-02-26 13:18:40 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2016-11-02 12:48:50 +01:00
}
2021-05-20 15:30:33 +02:00
2021-02-26 13:18:40 +01:00
if ( ! empty ( $arrayfields [ 'u.office_phone' ][ 'checked' ])) {
2021-06-02 13:03:20 +02:00
print '<td>' . dol_print_phone ( $obj -> office_phone , $obj -> country_code , 0 , $obj -> rowid , 'AC_TEL' , ' ' , 'phone' ) . " </td> \n " ;
2021-02-26 13:18:40 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2021-01-13 18:52:27 +01:00
}
2021-02-26 13:18:40 +01:00
if ( ! empty ( $arrayfields [ 'u.user_mobile' ][ 'checked' ])) {
2021-06-02 13:03:20 +02:00
print '<td>' . dol_print_phone ( $obj -> user_mobile , $obj -> country_code , 0 , $obj -> rowid , 'AC_TEL' , ' ' , 'mobile' ) . " </td> \n " ;
2021-02-26 13:18:40 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2021-01-13 18:52:27 +01:00
}
2021-02-26 13:18:40 +01:00
if ( ! empty ( $arrayfields [ 'u.email' ][ 'checked' ])) {
2021-05-20 14:25:54 +02:00
print '<td class="tdoverflowmax150">' . dol_print_email ( $obj -> email , $obj -> rowid , $obj -> fk_soc , 'AC_EMAIL' , 0 , 0 , 1 ) . " </td> \n " ;
2021-02-26 13:18:40 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2016-11-02 12:48:50 +01:00
}
2021-02-26 13:18:40 +01:00
if ( ! empty ( $arrayfields [ 'u.api_key' ][ 'checked' ])) {
2021-06-15 14:18:09 +02:00
print '<td>' ;
if ( $obj -> api_key ) {
if ( $canreadsecretapi ) {
print $obj -> api_key ;
} else {
print '<span class="opacitymedium">' . $langs -> trans ( " Hidden " ) . '</span>' ;
}
}
print '</td>' ;
2021-02-26 13:18:40 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2019-07-18 14:08:15 +02:00
}
2021-02-26 13:18:40 +01:00
if ( ! empty ( $arrayfields [ 'u.fk_soc' ][ 'checked' ])) {
2021-03-12 15:34:31 +01:00
print '<td class="tdoverflowmax200">' ;
2021-06-15 14:18:09 +02:00
if ( $obj -> fk_soc > 0 ) {
2020-01-30 01:48:28 +01:00
$companystatic -> id = $obj -> fk_soc ;
$companystatic -> name = $obj -> name ;
$companystatic -> canvas = $obj -> canvas ;
2017-10-13 13:28:26 +02:00
print $companystatic -> getNomUrl ( 1 );
2021-02-26 13:18:40 +01:00
} elseif ( $obj -> ldap_sid ) {
2021-03-12 15:34:31 +01:00
print '<span class="opacitymedium">' . $langs -> trans ( " DomainUser " ) . '</span>' ;
2020-05-21 15:05:19 +02:00
} else {
2021-03-12 15:34:31 +01:00
print '<span class="opacitymedium">' . $langs -> trans ( " InternalUser " ) . '</span>' ;
2017-10-13 13:28:26 +02:00
}
print '</td>' ;
2021-02-26 13:18:40 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2016-11-02 12:48:50 +01:00
}
2017-10-13 13:28:26 +02:00
// Multicompany enabled
2021-02-26 13:18:40 +01:00
if ( ! empty ( $conf -> multicompany -> enabled ) && is_object ( $mc ) && empty ( $conf -> global -> MULTICOMPANY_TRANSVERSE_MODE )) {
if ( ! empty ( $arrayfields [ 'u.entity' ][ 'checked' ])) {
2017-10-13 13:28:26 +02:00
print '<td>' ;
2021-02-26 13:18:40 +01:00
if ( ! $obj -> entity ) {
2017-10-13 13:28:26 +02:00
print $langs -> trans ( " AllEntities " );
2020-05-21 15:05:19 +02:00
} else {
2017-10-13 13:28:26 +02:00
$mc -> getInfo ( $obj -> entity );
print $mc -> label ;
}
print '</td>' ;
2021-02-26 13:18:40 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2016-11-02 12:48:50 +01:00
}
2017-10-13 13:28:26 +02:00
}
2020-12-03 00:40:41 +01:00
// Salary
2021-02-26 13:18:40 +01:00
if ( ! empty ( $arrayfields [ 'u.salary' ][ 'checked' ])) {
2021-06-15 14:18:09 +02:00
print '<td class="nowraponall right amount">' ;
if ( $obj -> salary ) {
if ( $canreadhrmdata ) {
print price ( $obj -> salary );
} else {
print '<span class="opacitymedium">' . $langs -> trans ( " Hidden " ) . '</span>' ;
}
}
print '</td>' ;
2021-02-26 13:18:40 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2017-01-23 12:29:05 +01:00
}
2017-10-13 13:28:26 +02:00
// Date last login
2021-02-26 13:18:40 +01:00
if ( ! empty ( $arrayfields [ 'u.datelastlogin' ][ 'checked' ])) {
2019-02-16 10:29:15 +01:00
print '<td class="nowrap center">' . dol_print_date ( $db -> jdate ( $obj -> datelastlogin ), " dayhour " ) . '</td>' ;
2021-02-26 13:18:40 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2016-11-02 12:48:50 +01:00
}
2017-10-13 13:28:26 +02:00
// Date previous login
2021-02-26 13:18:40 +01:00
if ( ! empty ( $arrayfields [ 'u.datepreviouslogin' ][ 'checked' ])) {
2019-02-16 10:29:15 +01:00
print '<td class="nowrap center">' . dol_print_date ( $db -> jdate ( $obj -> datepreviouslogin ), " dayhour " ) . '</td>' ;
2021-02-26 13:18:40 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2016-11-02 12:48:50 +01:00
}
2017-01-23 12:29:05 +01:00
2015-10-29 22:12:11 +01:00
// Extra fields
2017-11-27 15:24:29 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_print_fields.tpl.php' ;
2017-10-13 13:28:26 +02:00
// Fields from hook
2020-10-01 16:21:07 +02:00
$parameters = array ( 'arrayfields' => $arrayfields , 'object' => $object , 'obj' => $obj , 'i' => $i , 'totalarray' =>& $totalarray );
$reshook = $hookmanager -> executeHooks ( 'printFieldListValue' , $parameters , $object ); // Note that $action and $object may have been modified by hook
2017-10-13 13:28:26 +02:00
print $hookmanager -> resPrint ;
2016-11-02 12:48:50 +01:00
// Date creation
2021-02-26 13:18:40 +01:00
if ( ! empty ( $arrayfields [ 'u.datec' ][ 'checked' ])) {
2019-02-16 10:29:15 +01:00
print '<td class="center">' ;
2017-10-13 13:28:26 +02:00
print dol_print_date ( $db -> jdate ( $obj -> date_creation ), 'dayhour' , 'tzuser' );
print '</td>' ;
2021-02-26 13:18:40 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2017-10-13 13:28:26 +02:00
}
// Date modification
2021-02-26 13:18:40 +01:00
if ( ! empty ( $arrayfields [ 'u.tms' ][ 'checked' ])) {
2019-02-16 10:29:15 +01:00
print '<td class="center">' ;
2017-10-13 13:28:26 +02:00
print dol_print_date ( $db -> jdate ( $obj -> date_update ), 'dayhour' , 'tzuser' );
print '</td>' ;
2021-02-26 13:18:40 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2017-10-13 13:28:26 +02:00
}
// Status
2021-02-26 13:18:40 +01:00
if ( ! empty ( $arrayfields [ 'u.statut' ][ 'checked' ])) {
2020-10-07 15:01:28 +02:00
$userstatic -> statut = $obj -> statut ;
print '<td class="center">' . $userstatic -> getLibStatut ( 5 ) . '</td>' ;
2021-02-26 13:18:40 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2017-10-13 13:28:26 +02:00
}
// Action column
2020-10-01 16:21:07 +02:00
print '<td class="nowrap center">' ;
2021-02-26 13:18:40 +01:00
if ( $massactionbutton || $massaction ) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
2020-10-01 16:21:07 +02:00
$selected = 0 ;
2021-02-26 13:18:40 +01:00
if ( in_array ( $object -> id , $arrayofselected )) {
$selected = 1 ;
}
2020-10-01 16:21:07 +02:00
print '<input id="cb' . $object -> id . '" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $object -> id . '"' . ( $selected ? ' checked="checked"' : '' ) . '>' ;
}
print '</td>' ;
2021-02-26 13:18:40 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2014-08-03 11:36:00 +02:00
2020-10-01 16:21:07 +02:00
print '</tr>' . " \n " ;
2017-05-29 09:57:05 +02:00
2017-10-13 13:28:26 +02:00
$i ++ ;
2016-11-02 12:48:50 +01:00
}
2014-08-03 11:36:00 +02:00
2020-10-01 16:21:07 +02:00
// Show total line
include DOL_DOCUMENT_ROOT . '/core/tpl/list_print_total.tpl.php' ;
// If no record found
2021-02-26 13:18:40 +01:00
if ( $num == 0 ) {
2020-10-01 16:21:07 +02:00
$colspan = 1 ;
2021-02-26 13:18:40 +01:00
foreach ( $arrayfields as $key => $val ) {
if ( ! empty ( $val [ 'checked' ])) {
$colspan ++ ;
}
}
2020-10-01 16:21:07 +02:00
print '<tr><td colspan="' . $colspan . '" class="opacitymedium">' . $langs -> trans ( " NoRecordFound " ) . '</td></tr>' ;
}
$db -> free ( $resql );
2020-01-30 01:48:28 +01:00
$parameters = array ( 'arrayfields' => $arrayfields , 'sql' => $sql );
2020-10-01 16:21:07 +02:00
$reshook = $hookmanager -> executeHooks ( 'printFieldListFooter' , $parameters , $object ); // Note that $action and $object may have been modified by hook
2016-11-02 12:48:50 +01:00
print $hookmanager -> resPrint ;
2015-10-25 18:15:37 +01:00
2020-10-01 16:21:07 +02:00
print '</table>' . " \n " ;
print '</div>' . " \n " ;
print '</form>' . " \n " ;
2015-10-25 18:15:37 +01: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-09-17 16:00:41 +02:00
$db -> close ();