* Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * * 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 * along with this program. If not, see . */ /** * \file htdocs/user/index.php * \ingroup core * \brief Page of users */ require '../main.inc.php'; if(! empty($conf->multicompany->enabled)) dol_include_once('/multicompany/class/actions_multicompany.class.php'); if (! $user->rights->user->user->lire && ! $user->admin) accessforbidden(); $langs->load("users"); $langs->load("companies"); // Security check (for external users) $socid=0; if ($user->societe_id > 0) $socid = $user->societe_id; $sall=GETPOST('sall','alpha'); $search_user=GETPOST('search_user','alpha'); $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; $limit = $conf->liste_limit; if (! $sortfield) $sortfield="u.login"; if (! $sortorder) $sortorder="ASC"; $userstatic=new User($db); $companystatic = new Societe($db); /* * View */ llxHeader(); print_fiche_titre($langs->trans("ListOfUsers")); $sql = "SELECT u.rowid, u.name, u.firstname, u.admin, u.fk_societe, u.login,"; $sql.= " u.datec,"; $sql.= " u.tms as datem,"; $sql.= " u.datelastlogin,"; $sql.= " u.ldap_sid, u.statut, u.entity,"; $sql.= " s.nom, s.canvas"; $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON u.fk_societe = s.rowid"; if(! empty($conf->multicompany->enabled) && $conf->entity == 1 && (! empty($conf->multicompany->transverse_mode) || (! empty($user->admin) && empty($user->entity)))) { $sql.= " WHERE u.entity IS NOT NULL"; } else { $sql.= " WHERE u.entity IN (0,".$conf->entity.")"; } if (!empty($socid)) $sql.= " AND u.fk_societe = ".$socid; if ($search_user) { $sql.= " AND (u.login LIKE '%".$search_user."%' OR u.name LIKE '%".$search_user."%' OR u.firstname LIKE '%".$search_user."%')"; } if ($sall) $sql.= " AND (u.login LIKE '%".$db->escape($sall)."%' OR u.name LIKE '%".$db->escape($sall)."%' OR u.firstname LIKE '%".$db->escape($sall)."%' OR u.email LIKE '%".$db->escape($sall)."%' OR u.note LIKE '%".$db->escape($sall)."%')"; $sql.=$db->order($sortfield,$sortorder); $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); $i = 0; $param="search_user=$search_user&sall=$sall"; print ''; print ''; 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); 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); print_liste_field_titre($langs->trans("Status"),"index.php","u.status",$param,"",'align="right"',$sortfield,$sortorder); print "\n"; $var=True; while ($i < $num) { $obj = $db->fetch_object($result); $var=!$var; print ""; print ''; print ''; print ''; print "'; // Date creation print ''; // Date last login print ''; // Statut $userstatic->statut=$obj->statut; print ''; print "\n"; $i++; } print "
'.img_object($langs->trans("ShowUser"),"user").' '.$obj->login.''; 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 ''.ucfirst($obj->name).''.ucfirst($obj->firstname).'"; if ($obj->fk_societe) { $companystatic->id=$obj->fk_societe; $companystatic->nom=$obj->nom; $companystatic->canvas=$obj->canvas; print $companystatic->getNomUrl(1); } // Multicompany enabled else if (! empty($conf->multicompany->enabled)) { 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; } } } else if ($obj->ldap_sid) { print $langs->trans("DomainUser"); } else { print $langs->trans("InternalUser"); } print ''.dol_print_date($db->jdate($obj->datec),"dayhour").''.dol_print_date($db->jdate($obj->datelastlogin),"dayhour").''.$userstatic->getLibStatut(5).'
"; $db->free($result); } else { dol_print_error($db); } llxFooter(); $db->close(); ?>