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 >
2016-12-11 16:11:42 +01:00
* Copyright ( C ) 2004 - 2016 Laurent Destailleur < eldy @ users . sourceforge . net >
2012-12-30 15:13:49 +01:00
* Copyright ( C ) 2005 - 2012 Regis Houssin < regis . houssin @ capnetworks . com >
2015-07-15 20:30:33 +02:00
* Copyright ( C ) 2015 Alexandre Spangaro < aspangaro . dolibarr @ gmail . com >
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
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
*/
2009-01-31 01:15:34 +01:00
2005-01-18 20:44:23 +01:00
/**
2009-06-04 01:05:52 +02:00
* \file htdocs / user / index . php
* \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' ;
2012-10-09 09:34:12 +02:00
if ( ! empty ( $conf -> multicompany -> enabled ))
2012-12-08 15:35:08 +01:00
dol_include_once ( '/multicompany/class/actions_multicompany.class.php' , 'ActionsMulticompany' );
2011-08-19 09:22:17 +02:00
2002-05-06 21:10:48 +02:00
2012-10-09 09:34:12 +02:00
if ( ! $user -> rights -> user -> user -> lire && ! $user -> admin )
accessforbidden ();
2005-08-23 13:40:19 +02:00
2004-07-31 17:42:28 +02:00
$langs -> load ( " users " );
2007-02-26 01:00:03 +01:00
$langs -> load ( " companies " );
2016-01-01 23:44:23 +01:00
$langs -> load ( 'hrm' );
2004-07-31 17:42:28 +02:00
2010-10-29 18:08:54 +02:00
// Security check (for external users)
$socid = 0 ;
2012-10-09 09:34:12 +02:00
if ( $user -> societe_id > 0 )
$socid = $user -> societe_id ;
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
2015-10-29 22:12:11 +01:00
$limit = GETPOST ( " limit " ) ? GETPOST ( " limit " , " int " ) : $conf -> liste_limit ;
2012-10-09 09:34:12 +02:00
$sortfield = GETPOST ( 'sortfield' , 'alpha' );
$sortorder = GETPOST ( 'sortorder' , 'alpha' );
$page = GETPOST ( 'page' , 'int' );
2010-11-20 14:08:44 +01:00
if ( $page == - 1 ) { $page = 0 ; }
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 ;
2005-02-26 15:23:54 +01:00
if ( ! $sortfield ) $sortfield = " u.login " ;
2005-01-31 17:21:47 +01:00
if ( ! $sortorder ) $sortorder = " ASC " ;
2016-09-12 21:32:27 +02:00
// Initialize context for list
$contextpage = GETPOST ( 'contextpage' , 'aZ' ) ? GETPOST ( 'contextpage' , 'aZ' ) : 'userlist' ;
2015-10-25 18:15:37 +01:00
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
2016-09-12 21:32:27 +02:00
$hookmanager -> initHooks ( array ( $contextpage ));
2015-10-25 18:15:37 +01:00
$extrafields = new ExtraFields ( $db );
// fetch optionals attributes and labels
$extralabels = $extrafields -> fetch_name_optionals_label ( 'user' );
$search_array_options = $extrafields -> getOptionalsFromPost ( $extralabels , '' , 'search_' );
2007-02-26 01:00:03 +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 " ,
'u.lastname' => " Lastname " ,
2015-10-26 12:16:40 +01:00
'u.firstname' => " Firstname " ,
2015-10-25 18:15:37 +01:00
'u.accountancy_code' => " AccountancyCode " ,
'u.email' => " EMail " ,
'u.note' => " Note "
);
2015-11-11 17:05:18 +01:00
// Definition of fields for list
$arrayfields = array (
'u.login' => array ( 'label' => $langs -> trans ( " Login " ), 'checked' => 1 ),
'u.lastname' => array ( 'label' => $langs -> trans ( " Lastname " ), 'checked' => 1 ),
'u.firstname' => array ( 'label' => $langs -> trans ( " Firstname " ), 'checked' => 1 ),
'u.gender' => array ( 'label' => $langs -> trans ( " Gender " ), 'checked' => 0 ),
2016-02-07 23:07:16 +01:00
'u.employee' => array ( 'label' => $langs -> trans ( " Employee " ), 'checked' => ( $mode == 'employee' ? 1 : 0 )),
2015-11-11 17:05:18 +01:00
'u.accountancy_code' => array ( 'label' => $langs -> trans ( " AccountancyCode " ), 'checked' => 0 ),
'u.email' => array ( 'label' => $langs -> trans ( " EMail " ), 'checked' => 1 ),
'u.fk_soc' => array ( 'label' => $langs -> trans ( " Company " ), 'checked' => 1 ),
'u.entity' => array ( 'label' => $langs -> trans ( " Entity " ), 'checked' => 1 , 'enabled' => ( ! empty ( $conf -> multicompany -> enabled ) && empty ( $conf -> multicompany -> transverse_mode ))),
'u.fk_user' => array ( 'label' => $langs -> trans ( " HierarchicalResponsible " ), 'checked' => 1 ),
'u.datelastlogin' => array ( 'label' => $langs -> trans ( " LastConnexion " ), 'checked' => 1 , 'position' => 100 ),
'u.datepreviouslogin' => array ( 'label' => $langs -> trans ( " PreviousConnexion " ), 'checked' => 0 , 'position' => 110 ),
'u.datec' => array ( 'label' => $langs -> trans ( " DateCreation " ), 'checked' => 0 , 'position' => 500 ),
'u.tms' => array ( 'label' => $langs -> trans ( " DateModificationShort " ), 'checked' => 0 , 'position' => 500 ),
'u.statut' => array ( 'label' => $langs -> trans ( " Status " ), 'checked' => 1 , 'position' => 1000 ),
);
// Extra fields
if ( is_array ( $extrafields -> attribute_label ) && count ( $extrafields -> attribute_label ))
{
foreach ( $extrafields -> attribute_label as $key => $val )
{
$arrayfields [ " ef. " . $key ] = array ( 'label' => $extrafields -> attribute_label [ $key ], 'checked' => $extrafields -> attribute_list [ $key ], 'position' => $extrafields -> attribute_pos [ $key ], 'enabled' => $extrafields -> attribute_perms [ $key ]);
}
}
// Init search fields
$sall = GETPOST ( 'sall' , 'alpha' );
$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' );
$search_email = GETPOST ( 'search_email' , 'alpha' );
$search_statut = GETPOST ( 'search_statut' , 'alpha' );
$search_thirdparty = GETPOST ( 'search_thirdparty' , 'alpha' );
$search_supervisor = GETPOST ( 'search_supervisor' , 'alpha' );
$search_previousconn = GETPOST ( 'search_previousconn' , 'alpha' );
$optioncss = GETPOST ( 'optioncss' , 'alpha' );
// Default search
if ( $search_statut == '' ) $search_statut = '1' ;
2016-02-07 23:07:16 +01:00
if ( $mode == 'employee' ) $search_employee = 1 ;
2015-11-11 17:05:18 +01:00
2015-10-25 18:15:37 +01:00
/*
* Actions
*/
2016-11-02 12:48:50 +01:00
if ( GETPOST ( 'cancel' )) { $action = 'list' ; $massaction = '' ; }
if ( ! GETPOST ( 'confirmmassaction' ) && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills' ) { $massaction = '' ; }
2015-10-25 18:15:37 +01:00
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'doActions' , $parameters ); // Note that $action and $object may have been modified by some hooks
if ( $reshook < 0 ) setEventMessages ( $hookmanager -> error , $hookmanager -> errors , 'errors' );
2016-11-02 12:48:50 +01:00
if ( empty ( $reshook ))
2015-11-05 13:43:22 +01:00
{
2016-11-02 12:48:50 +01:00
// Selection of new fields
include DOL_DOCUMENT_ROOT . '/core/actions_changeselectedfields.inc.php' ;
// Purge search criteria
if ( GETPOST ( " button_removefilter_x " ) || GETPOST ( " button_removefilter.x " ) || GETPOST ( " button_removefilter " )) // All test are required to be compatible with all browsers
{
$search_user = " " ;
$search_login = " " ;
$search_lastname = " " ;
$search_firstname = " " ;
$search_gender = " " ;
$search_employee = " " ;
$search_accountancy_code = " " ;
$search_email = " " ;
$search_statut = " " ;
$search_thirdparty = " " ;
$search_supervisor = " " ;
$search_datelastlogin = " " ;
$search_datepreviouslogin = " " ;
$search_date_creation = " " ;
$search_date_update = " " ;
$search_array_options = array ();
}
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
2004-07-31 17:42:28 +02:00
2015-06-20 20:35:57 +02:00
$buttonviewhierarchy = '<form action="' . DOL_URL_ROOT . '/user/hierarchy.php' . (( $search_statut != '' && $search_statut >= 0 ) ? '?search_statut=' . $search_statut : '' ) . '" method="POST"><input type="submit" class="button" style="width:120px" name="viewcal" value="' . dol_escape_htmltag ( $langs -> trans ( " HierarchicView " )) . '"></form>' ;
2015-05-04 11:41:30 +02:00
2015-11-11 17:05:18 +01:00
$sql = " SELECT u.rowid, u.lastname, u.firstname, u.admin, u.fk_soc, u.login, u.email, u.accountancy_code, u.gender, u.employee, u.photo, " ;
2015-10-25 18:15:37 +01:00
$sql .= " u.datelastlogin, u.datepreviouslogin, " ;
2009-04-27 22:37:50 +02:00
$sql .= " u.ldap_sid, u.statut, u.entity, " ;
2015-10-25 18:15:37 +01:00
$sql .= " u.tms as date_update, u.datec as date_creation, " ;
2015-10-25 19:31:13 +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.email as email2, u2.gender as gender2, u2.photo as photo2, u2.entity as entity2, " ;
2014-10-04 17:20:17 +02:00
$sql .= " s.nom as name, s.canvas " ;
2015-10-25 18:15:37 +01:00
// Add fields from extrafields
2016-03-18 13:58:06 +01:00
foreach ( $extrafields -> attribute_label as $key => $val ) $sql .= ( $extrafields -> attribute_type [ $key ] != 'separate' ? " ,ef. " . $key . ' as options_' . $key : '' );
2015-10-25 18:15:37 +01:00
// Add fields from hooks
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'printFieldListSelect' , $parameters ); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager -> resPrint ;
2005-09-26 03:01:53 +02:00
$sql .= " FROM " . MAIN_DB_PREFIX . " user as u " ;
2015-10-29 22:12:11 +01:00
if ( is_array ( $extrafields -> attribute_label ) && count ( $extrafields -> attribute_label )) $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " user_extrafields as ef on (u.rowid = ef.fk_object) " ;
2015-04-18 18:11:01 +02:00
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " societe as s ON u.fk_soc = s.rowid " ;
2014-08-03 11:36:00 +02:00
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " user as u2 ON u.fk_user = u2.rowid " ;
2012-07-10 13:20:53 +02:00
if ( ! empty ( $conf -> multicompany -> enabled ) && $conf -> entity == 1 && ( ! empty ( $conf -> multicompany -> transverse_mode ) || ( ! empty ( $user -> admin ) && empty ( $user -> entity ))))
2011-08-20 00:15:22 +02:00
{
$sql .= " WHERE u.entity IS NOT NULL " ;
}
2011-08-19 09:22:17 +02:00
else
2011-08-20 00:15:22 +02:00
{
2014-05-30 12:32:19 +02:00
$sql .= " WHERE u.entity IN ( " . getEntity ( 'user' , 1 ) . " ) " ;
2011-08-20 00:15:22 +02:00
}
2015-05-13 07:46:12 +02:00
if ( $socid > 0 ) $sql .= " AND u.fk_soc = " . $socid ;
2015-10-26 12:16:40 +01:00
//if ($search_user != '') $sql.=natural_search(array('u.login', 'u.lastname', 'u.firstname'), $search_user);
2015-10-25 18:15:37 +01:00
if ( $search_supervisor > 0 ) $sql .= " AND u.fk_user = " . $search_supervisor ;
2015-05-13 07:46:12 +02:00
if ( $search_thirdparty != '' ) $sql .= natural_search ( array ( 's.nom' ), $search_thirdparty );
2015-10-25 18:15:37 +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 );
2015-11-11 17:05:18 +01:00
if ( $search_gender != '' && $search_gender != '-1' ) $sql .= " AND u.gender = ' " . $search_gender . " ' " ;
2016-04-10 01:00:27 +02:00
if ( is_numeric ( $search_employee ) && $search_employee >= 0 ) {
$sql .= ' AND u.employee = ' . ( int ) $search_employee ;
}
2015-10-26 12:16:40 +01:00
if ( $search_accountancy_code != '' ) $sql .= natural_search ( " u.accountancy_code " , $search_accountancy_code );
if ( $search_email != '' ) $sql .= natural_search ( " u.email " , $search_email );
2015-05-13 07:46:12 +02:00
if ( $search_statut != '' && $search_statut >= 0 ) $sql .= " AND (u.statut= " . $search_statut . " ) " ;
2015-10-26 12:16:40 +01:00
if ( $sall ) $sql .= natural_search ( array_keys ( $fieldstosearchall ), $sall );
2015-10-25 18:15:37 +01:00
// Add where from extra fields
foreach ( $search_array_options as $key => $val )
{
$crit = $val ;
$tmpkey = preg_replace ( '/search_options_/' , '' , $key );
$typ = $extrafields -> attribute_type [ $tmpkey ];
$mode = 0 ;
2016-04-04 16:02:29 +02:00
if ( in_array ( $typ , array ( 'int' , 'double' ))) $mode = 1 ; // Search on a numeric
2015-10-25 18:15:37 +01:00
if ( $val && ( ( $crit != '' && ! in_array ( $typ , array ( 'select' ))) || ! empty ( $crit )))
{
$sql .= natural_search ( 'ef.' . $tmpkey , $crit , $mode );
}
}
// Add where from hooks
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'printFieldListWhere' , $parameters ); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager -> resPrint ;
2011-11-02 20:17:55 +01:00
$sql .= $db -> order ( $sortfield , $sortorder );
2002-05-06 21:10:48 +02:00
2016-09-12 21:32:27 +02:00
$nbtotalofrecords = 0 ;
2016-07-06 10:28:34 +02:00
$result = $db -> query ( $sql );
if ( $result )
{
2016-09-12 21:32:27 +02:00
$nbtotalofrecords = $db -> num_rows ( $result );
2016-07-06 10:28:34 +02:00
}
$sql .= $db -> plimit ( $limit + 1 , $offset );
2016-09-12 21:32:27 +02:00
2002-05-06 21:10:48 +02:00
$result = $db -> query ( $sql );
2016-11-02 12:48:50 +01:00
if ( ! $result )
2002-12-23 00:40:26 +01:00
{
2016-11-02 12:48:50 +01:00
dol_print_error ( $db );
exit ;
}
$num = $db -> num_rows ( $result );
if ( $num == 1 && ! empty ( $conf -> global -> MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE ) && $sall )
{
$obj = $db -> fetch_object ( $resql );
$id = $obj -> rowid ;
header ( " Location: " . DOL_URL_ROOT . '/user/card.php?id=' . $id );
exit ;
}
llxHeader ( '' , $langs -> trans ( " ListOfUsers " ));
$param = '' ;
if ( ! empty ( $contextpage ) && $contextpage != $_SERVER [ " PHP_SELF " ]) $param .= '&contextpage=' . $contextpage ;
if ( $limit > 0 && $limit != $conf -> liste_limit ) $param .= '&limit=' . $limit ;
if ( $sall != '' ) $param .= '&sall=' . urlencode ( $sall );
if ( $search_user != '' ) $param .= " &search_user= " . $search_user ;
if ( $search_login != '' ) $param .= " &search_login= " . $search_login ;
if ( $search_lastname != '' ) $param .= " &search_lastname= " . $search_lastname ;
if ( $search_firstname != '' ) $param .= " &search_firstname= " . $search_firstname ;
if ( $search_gender != '' ) $param .= " &search_gender= " . $search_gender ;
if ( $search_employee != '' ) $param .= " &search_employee= " . $search_employee ;
if ( $search_accountancy_code != '' ) $param .= " &search_accountancy_code= " . $search_accountancy_code ;
if ( $search_email != '' ) $param .= " &search_email= " . $search_email ;
if ( $search_supervisor > 0 ) $param .= " &search_supervisor= " . $search_supervisor ;
if ( $search_statut != '' ) $param .= " &search_statut= " . $search_statut ;
if ( $optioncss != '' ) $param .= '&optioncss=' . $optioncss ;
if ( $mode != '' ) $param .= '&mode=' . $mode ;
// Add $param from extra fields
foreach ( $search_array_options as $key => $val )
{
$crit = $val ;
$tmpkey = preg_replace ( '/search_options_/' , '' , $key );
if ( $val != '' ) $param .= '&search_options_' . $tmpkey . '=' . urlencode ( $val );
}
$text = $langs -> trans ( " ListOfUsers " );
print '<form method="POST" id="searchFormList" action="' . $_SERVER [ " PHP_SELF " ] . '">' . " \n " ;
if ( $optioncss != '' ) print '<input type="hidden" name="optioncss" value="' . $optioncss . '">' ;
print '<input type="hidden" name="token" value="' . $_SESSION [ 'newtoken' ] . '">' ;
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 . '">' ;
print_barre_liste ( $text , $page , $_SERVER [ " PHP_SELF " ], $param , $sortfield , $sortorder , " " , $num , $nbtotalofrecords , 'title_generic' , 0 , '' , '' , $limit );
if ( $sall )
{
foreach ( $fieldstosearchall as $key => $val ) $fieldstosearchall [ $key ] = $langs -> trans ( $val );
print $langs -> trans ( " FilterOnInto " , $sall ) . join ( ', ' , $fieldstosearchall );
}
$moreforfilter = '' ;
$varpage = empty ( $contextpage ) ? $_SERVER [ " PHP_SELF " ] : $contextpage ;
$selectedfields = $form -> multiSelectArrayWithCheckbox ( 'selectedfields' , $arrayfields , $varpage ); // This also change content of $arrayfields
2016-11-27 13:49:46 +01:00
print '<div class="div-table-responsive">' ;
print '<table class="tagtable liste' . ( $moreforfilter ? " listwithfilterbefore " : " " ) . '">' . " \n " ;
2016-11-02 12:48:50 +01:00
print '<tr class="liste_titre">' ;
if ( ! empty ( $arrayfields [ 'u.login' ][ 'checked' ])) print_liste_field_titre ( $langs -> trans ( " Login " ), $_SERVER [ 'PHP_SELF' ], " u.login " , $param , " " , " " , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'u.lastname' ][ 'checked' ])) print_liste_field_titre ( $langs -> trans ( " Lastname " ), $_SERVER [ 'PHP_SELF' ], " u.lastname " , $param , " " , " " , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'u.firstname' ][ 'checked' ])) print_liste_field_titre ( $langs -> trans ( " FirstName " ), $_SERVER [ 'PHP_SELF' ], " u.firstname " , $param , " " , " " , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'u.gender' ][ 'checked' ])) print_liste_field_titre ( $langs -> trans ( " Gender " ), $_SERVER [ 'PHP_SELF' ], " u.gender " , $param , " " , " " , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'u.employee' ][ 'checked' ])) print_liste_field_titre ( $langs -> trans ( " Employee " ), $_SERVER [ 'PHP_SELF' ], " u.employee " , $param , " " , " " , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'u.accountancy_code' ][ 'checked' ])) print_liste_field_titre ( $langs -> trans ( " AccountancyCode " ), $_SERVER [ 'PHP_SELF' ], " u.accountancy_code " , $param , " " , " " , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'u.email' ][ 'checked' ])) print_liste_field_titre ( $langs -> trans ( " EMail " ), $_SERVER [ 'PHP_SELF' ], " u.email " , $param , " " , " " , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'u.fk_soc' ][ 'checked' ])) print_liste_field_titre ( $langs -> trans ( " Company " ), $_SERVER [ 'PHP_SELF' ], " u.fk_soc " , $param , " " , " " , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'u.entity' ][ 'checked' ])) print_liste_field_titre ( $langs -> trans ( " Entity " ), $_SERVER [ 'PHP_SELF' ], " u.entity " , $param , " " , " " , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'u.fk_user' ][ 'checked' ])) print_liste_field_titre ( $langs -> trans ( " HierarchicalResponsible " ), $_SERVER [ 'PHP_SELF' ], " u.fk_user " , $param , " " , " " , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'u.datelastlogin' ][ 'checked' ])) print_liste_field_titre ( $langs -> trans ( " LastConnexion " ), $_SERVER [ 'PHP_SELF' ], " u.datelastlogin " , $param , " " , 'align="center"' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'u.datepreviouslogin' ][ 'checked' ])) print_liste_field_titre ( $langs -> trans ( " PreviousConnexion " ), $_SERVER [ 'PHP_SELF' ], " u.datepreviouslogin " , $param , " " , 'align="center"' , $sortfield , $sortorder );
// Extra fields
if ( is_array ( $extrafields -> attribute_label ) && count ( $extrafields -> attribute_label ))
{
foreach ( $extrafields -> attribute_label as $key => $val )
{
if ( ! empty ( $arrayfields [ " ef. " . $key ][ 'checked' ]))
{
$align = $extrafields -> getAlignFlag ( $key );
print_liste_field_titre ( $extralabels [ $key ], $_SERVER [ " PHP_SELF " ], " ef. " . $key , " " , $param ,( $align ? 'align="' . $align . '"' : '' ), $sortfield , $sortorder );
}
}
}
// Hook fields
$parameters = array ( 'arrayfields' => $arrayfields );
$reshook = $hookmanager -> executeHooks ( 'printFieldListTitle' , $parameters ); // Note that $action and $object may have been modified by hook
print $hookmanager -> resPrint ;
if ( ! empty ( $arrayfields [ 'u.datec' ][ 'checked' ])) print_liste_field_titre ( $langs -> trans ( " DateCreationShort " ), $_SERVER [ " PHP_SELF " ], " u.datec " , " " , $param , 'align="center" class="nowrap"' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'u.tms' ][ 'checked' ])) print_liste_field_titre ( $langs -> trans ( " DateModificationShort " ), $_SERVER [ " PHP_SELF " ], " u.tms " , " " , $param , 'align="center" class="nowrap"' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'u.statut' ][ 'checked' ])) print_liste_field_titre ( $langs -> trans ( " Status " ), $_SERVER [ " PHP_SELF " ], " u.statut " , " " , $param , 'align="center"' , $sortfield , $sortorder );
print_liste_field_titre ( $selectedfields , $_SERVER [ " PHP_SELF " ], " " , '' , '' , 'align="right"' , $sortfield , $sortorder , 'maxwidthsearch ' );
print " </tr> \n " ;
// Search bar
print '<tr class="liste_titre">' ;
if ( ! empty ( $arrayfields [ 'u.login' ][ 'checked' ]))
{
2016-12-11 16:11:42 +01:00
print '<td class="liste_titre"><input type="text" name="search_login" size="6" value="' . $search_login . '"></td>' ;
2016-11-02 12:48:50 +01:00
}
if ( ! empty ( $arrayfields [ 'u.lastname' ][ 'checked' ]))
{
2016-12-11 16:11:42 +01:00
print '<td class="liste_titre"><input type="text" name="search_lastname" size="6" value="' . $search_lastname . '"></td>' ;
2016-11-02 12:48:50 +01:00
}
if ( ! empty ( $arrayfields [ 'u.firstname' ][ 'checked' ]))
{
2016-12-11 16:11:42 +01:00
print '<td class="liste_titre"><input type="text" name="search_firstname" size="6" value="' . $search_firstname . '"></td>' ;
2016-11-02 12:48:50 +01:00
}
if ( ! empty ( $arrayfields [ 'u.gender' ][ 'checked' ]))
{
2016-12-11 16:11:42 +01:00
print '<td class="liste_titre">' ;
2016-11-02 12:48:50 +01:00
$arraygender = array ( 'man' => $langs -> trans ( " Genderman " ), 'woman' => $langs -> trans ( " Genderwoman " ));
print $form -> selectarray ( 'search_gender' , $arraygender , $search_gender , 1 );
print '</td>' ;
}
if ( ! empty ( $arrayfields [ 'u.employee' ][ 'checked' ]))
{
2016-12-11 16:11:42 +01:00
print '<td class="liste_titre">' ;
2016-11-02 12:48:50 +01:00
print $form -> selectyesno ( 'search_employee' , $search_employee , 1 , false , 1 );
print '</td>' ;
}
if ( ! empty ( $arrayfields [ 'u.accountancy_code' ][ 'checked' ]))
{
2016-12-11 16:11:42 +01:00
print '<td class="liste_titre"><input type="text" name="search_accountancy_code" size="4" value="' . $search_accountancy_code . '"></td>' ;
2016-11-02 12:48:50 +01:00
}
if ( ! empty ( $arrayfields [ 'u.email' ][ 'checked' ]))
{
2016-12-11 16:11:42 +01:00
print '<td class="liste_titre"><input type="text" name="search_email" size="6" value="' . $search_email . '"></td>' ;
2016-11-02 12:48:50 +01:00
}
if ( ! empty ( $arrayfields [ 'u.fk_soc' ][ 'checked' ]))
{
2016-12-11 16:11:42 +01:00
print '<td class="liste_titre"><input type="text" name="search_thirdparty" size="6" value="' . $search_thirdparty . '"></td>' ;
2016-11-02 12:48:50 +01:00
}
if ( ! empty ( $arrayfields [ 'u.entity' ][ 'checked' ]))
{
2016-12-11 16:11:42 +01:00
print '<td class="liste_titre"></td>' ;
2016-11-02 12:48:50 +01:00
}
if ( ! empty ( $arrayfields [ 'u.fk_user' ][ 'checked' ]))
{
2016-12-11 16:11:42 +01:00
print '<td class="liste_titre"></td>' ;
2016-11-02 12:48:50 +01:00
}
if ( ! empty ( $arrayfields [ 'u.datelastlogin' ][ 'checked' ]))
{
2016-12-11 16:11:42 +01:00
print '<td class="liste_titre"></td>' ;
2016-11-02 12:48:50 +01:00
}
if ( ! empty ( $arrayfields [ 'u.datepreviouslogin' ][ 'checked' ]))
{
2016-12-11 16:11:42 +01:00
print '<td class="liste_titre"></td>' ;
2016-11-02 12:48:50 +01:00
}
// Extra fields
if ( is_array ( $extrafields -> attribute_label ) && count ( $extrafields -> attribute_label ))
{
foreach ( $extrafields -> attribute_label as $key => $val )
{
if ( ! empty ( $arrayfields [ " ef. " . $key ][ 'checked' ]))
{
$align = $extrafields -> getAlignFlag ( $key );
$typeofextrafield = $extrafields -> attribute_type [ $key ];
print '<td class="liste_titre' . ( $align ? ' ' . $align : '' ) . '">' ;
if ( in_array ( $typeofextrafield , array ( 'varchar' , 'int' , 'double' , 'select' )))
{
$crit = $val ;
$tmpkey = preg_replace ( '/search_options_/' , '' , $key );
$searchclass = '' ;
if ( in_array ( $typeofextrafield , array ( 'varchar' , 'select' ))) $searchclass = 'searchstring' ;
if ( in_array ( $typeofextrafield , array ( 'int' , 'double' ))) $searchclass = 'searchnum' ;
print '<input class="flat' . ( $searchclass ? ' ' . $searchclass : '' ) . '" size="4" type="text" name="search_options_' . $tmpkey . '" value="' . dol_escape_htmltag ( $search_array_options [ 'search_options_' . $tmpkey ]) . '">' ;
}
print '</td>' ;
}
}
}
// Fields from hook
$parameters = array ( 'arrayfields' => $arrayfields );
$reshook = $hookmanager -> executeHooks ( 'printFieldListOption' , $parameters ); // Note that $action and $object may have been modified by hook
print $hookmanager -> resPrint ;
if ( ! empty ( $arrayfields [ 'u.datec' ][ 'checked' ]))
{
// Date creation
print '<td class="liste_titre">' ;
print '</td>' ;
}
if ( ! empty ( $arrayfields [ 'u.tms' ][ 'checked' ]))
{
// Date modification
print '<td class="liste_titre">' ;
print '</td>' ;
}
if ( ! empty ( $arrayfields [ 'u.statut' ][ 'checked' ]))
{
// Status
print '<td class="liste_titre" align="center">' ;
print $form -> selectarray ( 'search_statut' , array ( '-1' => '' , '0' => $langs -> trans ( 'Disabled' ), '1' => $langs -> trans ( 'Enabled' )), $search_statut );
print '</td>' ;
}
// Action column
print '<td class="liste_titre" align="right">' ;
$searchpitco = $form -> showFilterAndCheckAddButtons ( 0 );
print $searchpitco ;
print '</td>' ;
print " </tr> \n " ;
$user2 = new User ( $db );
$var = True ;
$i = 0 ;
while ( $i < min ( $num , $limit ))
{
$obj = $db -> fetch_object ( $result );
$var =! $var ;
$userstatic -> id = $obj -> rowid ;
$userstatic -> ref = $obj -> label ;
$userstatic -> login = $obj -> login ;
$userstatic -> statut = $obj -> statut ;
$userstatic -> email = $obj -> email ;
$userstatic -> gender = $obj -> gender ;
$userstatic -> societe_id = $obj -> fk_soc ;
$userstatic -> firstname = $obj -> firstname ;
$userstatic -> lastname = $obj -> lastname ;
$userstatic -> employee = $obj -> employee ;
$userstatic -> photo = $obj -> photo ;
2015-11-11 17:05:18 +01:00
2016-11-02 12:48:50 +01:00
$li = $userstatic -> getNomUrl ( - 1 , '' , 0 , 0 , 24 , 1 , 'login' );
2014-05-30 12:32:19 +02:00
2016-11-02 12:48:50 +01:00
print " <tr " . $bc [ $var ] . " > " ;
2015-10-25 18:15:37 +01:00
if ( ! empty ( $arrayfields [ 'u.login' ][ 'checked' ]))
2016-11-02 12:48:50 +01:00
{
print '<td>' ;
print $li ;
if ( ! empty ( $conf -> multicompany -> enabled ) && $obj -> admin && ! $obj -> entity )
{
print img_picto ( $langs -> trans ( " SuperAdministrator " ), 'redstar' );
}
else if ( $obj -> admin )
{
print img_picto ( $langs -> trans ( " Administrator " ), 'star' );
}
print '</td>' ;
}
2015-10-25 18:15:37 +01:00
if ( ! empty ( $arrayfields [ 'u.lastname' ][ 'checked' ]))
2016-11-02 12:48:50 +01:00
{
print '<td>' . $obj -> lastname . '</td>' ;
}
2015-10-25 18:15:37 +01:00
if ( ! empty ( $arrayfields [ 'u.firstname' ][ 'checked' ]))
2016-11-02 12:48:50 +01:00
{
print '<td>' . $obj -> firstname . '</td>' ;
}
2015-11-11 17:05:18 +01:00
if ( ! empty ( $arrayfields [ 'u.gender' ][ 'checked' ]))
2016-11-02 12:48:50 +01:00
{
print '<td>' ;
if ( $obj -> gender ) print $langs -> trans ( " Gender " . $obj -> gender );
print '</td>' ;
}
2015-11-11 17:05:18 +01:00
if ( ! empty ( $arrayfields [ 'u.employee' ][ 'checked' ]))
2016-11-02 12:48:50 +01:00
{
print '<td>' . yn ( $obj -> employee ) . '</td>' ;
}
if ( ! empty ( $arrayfields [ 'u.accountancy_code' ][ 'checked' ]))
{
print '<td>' . $obj -> accountancy_code . '</td>' ;
}
2015-10-26 12:16:40 +01:00
if ( ! empty ( $arrayfields [ 'u.email' ][ 'checked' ]))
2016-11-02 12:48:50 +01:00
{
print '<td>' . $obj -> email . '</td>' ;
}
if ( ! empty ( $arrayfields [ 'u.fk_soc' ][ 'checked' ]))
{
print " <td> " ;
if ( $obj -> fk_soc )
{
$companystatic -> id = $obj -> fk_soc ;
$companystatic -> name = $obj -> name ;
$companystatic -> canvas = $obj -> canvas ;
print $companystatic -> getNomUrl ( 1 );
}
else if ( $obj -> ldap_sid )
{
print $langs -> trans ( " DomainUser " );
}
else
{
print $langs -> trans ( " InternalUser " );
}
print '</td>' ;
}
// Multicompany enabled
if ( ! empty ( $conf -> multicompany -> enabled ) && empty ( $conf -> multicompany -> transverse_mode ))
2015-10-26 12:16:40 +01:00
{
2016-11-02 12:48:50 +01:00
if ( ! empty ( $arrayfields [ 'u.entity' ][ 'checked' ]))
{
print '<td>' ;
if ( ! $obj -> entity )
{
print $langs -> trans ( " AllEntities " );
}
else
{
// $mc is defined in conf.class.php if multicompany enabled.
if ( is_object ( $mc ))
{
$mc -> getInfo ( $obj -> entity );
print $mc -> label ;
}
}
print '</td>' ;
}
2015-10-25 18:15:37 +01:00
}
2016-11-02 12:48:50 +01:00
// Supervisor
2015-10-25 18:15:37 +01:00
if ( ! empty ( $arrayfields [ 'u.fk_user' ][ 'checked' ]))
2016-11-02 12:48:50 +01:00
{
// 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 ;
$user2 -> email = $obj -> email2 ;
$user2 -> societe_id = $obj -> fk_soc2 ;
print $user2 -> getNomUrl ( - 1 , '' , 0 , 0 , 24 , 0 , '' );
if ( ! empty ( $conf -> multicompany -> enabled ) && $obj -> admin2 && ! $obj -> entity2 )
{
print img_picto ( $langs -> trans ( " SuperAdministrator " ), 'redstar' );
}
else if ( $obj -> admin2 )
{
print img_picto ( $langs -> trans ( " Administrator " ), 'star' );
}
}
print '</td>' ;
}
// Date last login
2015-10-25 18:15:37 +01:00
if ( ! empty ( $arrayfields [ 'u.datelastlogin' ][ 'checked' ]))
2016-11-02 12:48:50 +01:00
{
print '<td class="nowrap" align="center">' . dol_print_date ( $db -> jdate ( $obj -> datelastlogin ), " dayhour " ) . '</td>' ;
}
// Date previous login
2015-10-25 18:15:37 +01:00
if ( ! empty ( $arrayfields [ 'u.datepreviouslogin' ][ 'checked' ]))
2016-11-02 12:48:50 +01:00
{
print '<td class="nowrap" align="center">' . dol_print_date ( $db -> jdate ( $obj -> datepreviouslogin ), " dayhour " ) . '</td>' ;
}
2015-10-29 22:12:11 +01:00
// Extra fields
if ( is_array ( $extrafields -> attribute_label ) && count ( $extrafields -> attribute_label ))
{
foreach ( $extrafields -> attribute_label as $key => $val )
{
2016-04-04 16:02:29 +02:00
if ( ! empty ( $arrayfields [ " ef. " . $key ][ 'checked' ]))
{
2016-11-02 12:48:50 +01:00
print '<td' ;
$align = $extrafields -> getAlignFlag ( $key );
if ( $align ) print ' align="' . $align . '"' ;
print '>' ;
$tmpkey = 'options_' . $key ;
print $extrafields -> showOutputField ( $key , $obj -> $tmpkey , '' , 1 );
2016-04-04 16:02:29 +02:00
print '</td>' ;
}
2015-10-29 22:12:11 +01:00
}
}
2015-10-25 18:15:37 +01:00
// Fields from hook
2016-11-02 12:48:50 +01:00
$parameters = array ( 'arrayfields' => $arrayfields , 'obj' => $obj );
$reshook = $hookmanager -> executeHooks ( 'printFieldListValue' , $parameters ); // Note that $action and $object may have been modified by hook
2015-10-25 18:15:37 +01:00
print $hookmanager -> resPrint ;
2016-11-02 12:48:50 +01:00
// Date creation
2015-10-25 18:15:37 +01:00
if ( ! empty ( $arrayfields [ 'u.datec' ][ 'checked' ]))
{
2016-11-02 12:48:50 +01:00
print '<td align="center">' ;
print dol_print_date ( $db -> jdate ( $obj -> date_creation ), 'dayhour' );
2015-10-25 18:15:37 +01:00
print '</td>' ;
}
2016-11-02 12:48:50 +01:00
// Date modification
2015-10-25 18:15:37 +01:00
if ( ! empty ( $arrayfields [ 'u.tms' ][ 'checked' ]))
{
2016-11-02 12:48:50 +01:00
print '<td align="center">' ;
print dol_print_date ( $db -> jdate ( $obj -> date_update ), 'dayhour' );
2015-10-25 18:15:37 +01:00
print '</td>' ;
}
2016-11-02 12:48:50 +01:00
// Status
2015-10-25 18:15:37 +01:00
if ( ! empty ( $arrayfields [ 'u.statut' ][ 'checked' ]))
{
2016-11-02 12:48:50 +01:00
$userstatic -> statut = $obj -> statut ;
print '<td align="center">' . $userstatic -> getLibStatut ( 3 ) . '</td>' ;
2015-10-25 18:15:37 +01:00
}
// Action column
2016-11-02 12:48:50 +01:00
print '<td></td>' ;
2014-08-03 11:36:00 +02:00
2016-11-02 12:48:50 +01:00
print " </tr> \n " ;
$i ++ ;
}
2014-08-03 11:36:00 +02:00
2016-11-02 12:48:50 +01:00
$parameters = array ( 'arrayfields' => $arrayfields , 'sql' => $sql );
$reshook = $hookmanager -> executeHooks ( 'printFieldListFooter' , $parameters ); // Note that $action and $object may have been modified by hook
print $hookmanager -> resPrint ;
2015-10-25 18:15:37 +01:00
2016-11-02 12:48:50 +01:00
print " </table> " ;
2016-11-27 13:49:46 +01:00
print '</div>' ;
2016-11-02 12:48:50 +01:00
print " </form> \n " ;
2015-10-25 18:15:37 +01:00
2016-11-27 13:49:46 +01:00
$db -> free ( $result );
2002-05-06 21:10:48 +02:00
2011-08-27 16:24:16 +02:00
llxFooter ();
2012-09-17 16:00:41 +02:00
$db -> close ();