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 >
2011-05-25 11:51:01 +02:00
* Copyright ( C ) 2004 - 2011 Laurent Destailleur < eldy @ users . sourceforge . net >
2011-08-20 00:15:22 +02:00
* Copyright ( C ) 2005 - 2011 Regis Houssin < regis @ dolibarr . fr >
2002-05-06 21:10:48 +02:00
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation ; either version 2 of the License , or
* ( 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
2010-03-01 09:08:49 +01:00
require ( " ../main.inc.php " );
2011-08-21 12:01:36 +02:00
if ( ! empty ( $conf -> multicompany -> enabled )) dol_include_once ( " /multicompany/class/actions_multicompany.class.php " );
2011-08-19 09:22:17 +02:00
2002-05-06 21:10:48 +02:00
2005-10-22 15:48:19 +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 " );
2004-07-31 17:42:28 +02:00
2010-10-29 18:08:54 +02:00
// Security check (for external users)
$socid = 0 ;
if ( $user -> societe_id > 0 ) $socid = $user -> societe_id ;
2005-09-06 21:17:12 +02:00
$sall = isset ( $_GET [ " sall " ]) ? $_GET [ " sall " ] : $_POST [ " sall " ];
2010-11-20 14:08:44 +01:00
$sortfield = GETPOST ( " sortfield " , 'alpha' );
$sortorder = GETPOST ( " sortorder " , 'alpha' );
$page = GETPOST ( " page " , 'int' );
if ( $page == - 1 ) { $page = 0 ; }
$offset = $conf -> liste_limit * $page ;
$pageprev = $page - 1 ;
$pagenext = $page + 1 ;
2005-01-31 17:21:47 +01:00
$limit = $conf -> liste_limit ;
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 " ;
2007-02-26 01:00:03 +01:00
$userstatic = new User ( $db );
2010-10-29 18:08:54 +02:00
$companystatic = new Societe ( $db );
2007-02-26 01:00:03 +01:00
2009-01-31 01:15:34 +01:00
/*
* View
*/
2005-01-31 17:21:47 +01:00
llxHeader ();
2004-07-31 17:42:28 +02:00
2009-03-02 20:07:12 +01:00
print_fiche_titre ( $langs -> trans ( " ListOfUsers " ));
2002-07-03 14:46:00 +02:00
2007-11-16 04:30:07 +01:00
$sql = " SELECT u.rowid, u.name, u.firstname, u.admin, u.fk_societe, u.login, " ;
2010-05-08 18:29:37 +02:00
$sql .= " u.datec, " ;
$sql .= " u.tms as datem, " ;
$sql .= " u.datelastlogin, " ;
2009-04-27 22:37:50 +02:00
$sql .= " u.ldap_sid, u.statut, u.entity, " ;
2010-10-29 18:08:54 +02:00
$sql .= " s.nom, s.canvas " ;
2005-09-26 03:01:53 +02:00
$sql .= " FROM " . MAIN_DB_PREFIX . " user as u " ;
2007-06-12 00:51:47 +02:00
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " societe as s ON u.fk_societe = s.rowid " ;
2011-08-21 12:01:36 +02:00
if ( ! empty ( $conf -> multicompany -> enabled ) && $conf -> entity == 1 && ( $conf -> global -> MULTICOMPANY_TRANSVERSE_MODE || ( $user -> admin && ! $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
{
$sql .= " WHERE u.entity IN (0, " . $conf -> entity . " ) " ;
}
2010-10-29 18:08:54 +02:00
if ( ! empty ( $socid )) $sql .= " AND u.fk_societe = " . $socid ;
2005-09-26 03:01:53 +02:00
if ( $_POST [ " search_user " ])
{
2009-01-31 01:15:34 +01:00
$sql .= " AND (u.login like '% " . $_POST [ " search_user " ] . " %' OR u.name like '% " . $_POST [ " search_user " ] . " %' OR u.firstname like '% " . $_POST [ " search_user " ] . " %') " ;
2005-01-31 17:21:47 +01:00
}
2007-03-10 23:14:14 +01:00
if ( $sall ) $sql .= " AND (u.login like '% " . $sall . " %' OR u.name like '% " . $sall . " %' OR u.firstname like '% " . $sall . " %' OR u.email like '% " . $sall . " %' OR u.note like '% " . $sall . " %') " ;
2005-09-26 03:01:53 +02:00
if ( $sortfield ) $sql .= " ORDER BY $sortfield $sortorder " ;
2002-05-06 21:10:48 +02:00
$result = $db -> query ( $sql );
2002-12-23 00:40:26 +01:00
if ( $result )
{
2005-03-06 17:01:38 +01:00
$num = $db -> num_rows ( $result );
2004-11-03 23:00:47 +01:00
$i = 0 ;
2005-09-06 21:17:12 +02:00
$param = " search_user= $search_user &sall= $sall " ;
2011-08-20 00:15:22 +02:00
print '<table class="noborder" width="100%">' ;
2004-11-03 23:00:47 +01:00
print '<tr class="liste_titre">' ;
2007-11-11 16:55:45 +01:00
print_liste_field_titre ( $langs -> trans ( " Login " ), " index.php " , " u.login " , $param , " " , " " , $sortfield , $sortorder );
print_liste_field_titre ( $langs -> trans ( " LastName " ), " index.php " , " u.name " , $param , " " , " " , $sortfield , $sortorder );
print_liste_field_titre ( $langs -> trans ( " FirstName " ), " index.php " , " u.firstname " , $param , " " , " " , $sortfield , $sortorder );
print_liste_field_titre ( $langs -> trans ( " Company " ), " index.php " , " u.fk_societe " , $param , " " , " " , $sortfield , $sortorder );
2009-04-27 22:37:50 +02:00
print_liste_field_titre ( $langs -> trans ( " DateCreation " ), " index.php " , " u.datec " , $param , " " , 'align="center"' , $sortfield , $sortorder );
print_liste_field_titre ( $langs -> trans ( " LastConnexion " ), " index.php " , " u.datelastlogin " , $param , " " , 'align="center"' , $sortfield , $sortorder );
2007-11-11 16:55:45 +01:00
print_liste_field_titre ( $langs -> trans ( " Status " ), " index.php " , " u.status " , $param , " " , 'align="right"' , $sortfield , $sortorder );
2004-11-03 23:00:47 +01:00
print " </tr> \n " ;
$var = True ;
while ( $i < $num )
2002-12-23 00:40:26 +01:00
{
2005-03-06 17:01:38 +01:00
$obj = $db -> fetch_object ( $result );
2004-11-03 23:00:47 +01:00
$var =! $var ;
print " <tr $bc[$var] > " ;
2007-02-26 01:00:03 +01:00
print '<td><a href="fiche.php?id=' . $obj -> rowid . '">' . img_object ( $langs -> trans ( " ShowUser " ), " user " ) . ' ' . $obj -> login . '</a>' ;
2011-08-21 12:01:36 +02:00
if ( ! empty ( $conf -> multicompany -> enabled ) && $obj -> admin && ! $obj -> entity )
2004-11-03 23:00:47 +01:00
{
2011-08-17 17:56:22 +02:00
print img_picto ( $langs -> trans ( " SuperAdministrator " ), 'redstar' );
2009-04-27 22:37:50 +02:00
}
else if ( $obj -> admin )
{
print img_picto ( $langs -> trans ( " Administrator " ), 'star' );
2004-11-03 23:00:47 +01:00
}
2007-02-26 01:00:03 +01:00
print '</td>' ;
2005-02-26 15:23:54 +01:00
print '<td>' . ucfirst ( $obj -> name ) . '</td>' ;
print '<td>' . ucfirst ( $obj -> firstname ) . '</td>' ;
2005-09-26 03:01:53 +02:00
print " <td> " ;
if ( $obj -> fk_societe )
{
2010-10-29 18:08:54 +02:00
$companystatic -> id = $obj -> fk_societe ;
$companystatic -> nom = $obj -> nom ;
$companystatic -> canvas = $obj -> canvas ;
print $companystatic -> getNomUrl ( 1 );
2005-09-26 03:01:53 +02:00
}
2011-08-21 12:01:36 +02:00
else if ( ! empty ( $conf -> multicompany -> enabled ))
2011-08-19 09:22:17 +02:00
{
2011-09-22 12:55:37 +02:00
if ( ! $obj -> entity )
2011-08-20 00:15:22 +02:00
{
print $langs -> trans ( " AllEntities " );
}
else
{
$mc = new ActionsMulticompany ( $db );
$mc -> getInfo ( $obj -> entity );
print $mc -> label ;
}
2011-08-19 09:22:17 +02:00
}
2006-06-24 17:13:29 +02:00
else if ( $obj -> ldap_sid )
{
print $langs -> trans ( " DomainUser " );
}
2011-08-20 00:15:22 +02:00
else
{
print $langs -> trans ( " InternalUser " );
}
2005-09-26 03:01:53 +02:00
print '</td>' ;
2009-01-31 01:15:34 +01:00
2007-11-16 04:30:07 +01:00
// Date creation
2011-05-25 11:51:01 +02:00
print '<td nowrap="nowrap" align="center">' . dol_print_date ( $db -> jdate ( $obj -> datec ), " dayhour " ) . '</td>' ;
2007-11-16 04:30:07 +01:00
// Date last login
2010-05-08 18:29:37 +02:00
print '<td nowrap="nowrap" align="center">' . dol_print_date ( $db -> jdate ( $obj -> datelastlogin ), " dayhour " ) . '</td>' ;
2007-02-26 01:00:03 +01:00
// Statut
$userstatic -> statut = $obj -> statut ;
print '<td width="100" align="right">' . $userstatic -> getLibStatut ( 5 ) . '</td>' ;
2004-11-03 23:00:47 +01:00
print " </tr> \n " ;
$i ++ ;
2002-12-23 00:40:26 +01:00
}
2004-11-03 23:00:47 +01:00
print " </table> " ;
2005-03-06 17:01:38 +01:00
$db -> free ( $result );
2002-12-23 00:40:26 +01:00
}
2004-11-03 23:00:47 +01:00
else
2002-12-23 00:40:26 +01:00
{
2009-02-20 23:53:15 +01:00
dol_print_error ( $db );
2002-05-06 21:10:48 +02:00
}
$db -> close ();
2011-08-27 16:24:16 +02:00
llxFooter ();
2002-05-06 21:10:48 +02:00
?>