dolibarr/htdocs/user/group/index.php

133 lines
4.4 KiB
PHP
Raw Normal View History

2005-01-27 16:55:40 +01:00
<?php
/* Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
2012-12-30 15:13:49 +01:00
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
2011-08-19 09:22:17 +02:00
* Copyright (C) 2011 Herve Prot <herve.prot@symeos.com>
2005-01-27 16:55:40 +01: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 3 of the License, or
2005-01-27 16:55:40 +01: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/>.
2005-01-27 16:55:40 +01:00
*/
2009-03-02 20:07:12 +01:00
/**
* \file htdocs/user/group/index.php
* \ingroup core
* \brief Page of user groups
*/
2005-01-27 16:55:40 +01:00
require '../../main.inc.php';
2005-01-27 16:55:40 +01:00
2010-11-08 12:40:52 +01:00
if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS))
{
2012-10-09 09:34:12 +02:00
if (! $user->rights->user->group_advance->read && ! $user->admin)
accessforbidden();
2010-11-08 12:40:52 +01:00
}
2005-01-27 16:55:40 +01:00
$langs->load("users");
$sall=GETPOST('sall');
$search_group=GETPOST('search_group');
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; }
$offset = $conf->liste_limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
2009-03-02 20:07:12 +01:00
if (! $sortfield) $sortfield="g.nom";
if (! $sortorder) $sortorder="ASC";
2009-03-02 20:07:12 +01:00
/*
* View
*/
2005-01-27 16:55:40 +01:00
llxHeader();
2009-03-02 20:07:12 +01:00
print_fiche_titre($langs->trans("ListOfGroups"));
2005-01-27 16:55:40 +01:00
$sql = "SELECT g.rowid, g.nom, g.entity, g.datec, COUNT(DISTINCT ugu.fk_user) as nb";
2011-02-12 00:39:21 +01:00
$sql.= " FROM ".MAIN_DB_PREFIX."usergroup as g";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_usergroup = g.rowid";
if (! empty($conf->multicompany->enabled) && $conf->entity == 1 && ($conf->multicompany->transverse_mode || ($user->admin && ! $user->entity)))
2011-08-20 00:15:22 +02:00
{
$sql.= " WHERE g.entity IS NOT NULL";
}
else
{
$sql.= " WHERE g.entity IN (0,".$conf->entity.")";
}
2012-10-09 09:34:12 +02:00
if (! empty($search_group))
{
2012-10-09 09:34:12 +02:00
$sql .= " AND (g.nom LIKE '%".$db->escape($search_group)."%' OR g.note LIKE '%".$db->escape($search_group)."%')";
}
2011-11-02 22:15:59 +01:00
if ($sall) $sql.= " AND (g.nom LIKE '%".$db->escape($sall)."%' OR g.note LIKE '%".$db->escape($sall)."%')";
2011-02-12 00:39:21 +01:00
$sql.= " GROUP BY g.rowid, g.nom, g.entity, g.datec";
$sql.= $db->order($sortfield,$sortorder);
$resql = $db->query($sql);
if ($resql)
2005-01-27 16:55:40 +01:00
{
$num = $db->num_rows($resql);
$i = 0;
2012-10-09 11:56:39 +02:00
$param="&search_group=".urlencode($search_group)."&amp;sall=".urlencode($sall);
2011-08-20 11:03:38 +02:00
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
2011-02-12 00:39:21 +01:00
print_liste_field_titre($langs->trans("Group"),$_SERVER["PHP_SELF"],"g.nom",$param,"","",$sortfield,$sortorder);
2011-08-19 09:22:17 +02:00
//multicompany
if(! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode) && $conf->entity == 1)
2011-08-20 00:15:22 +02:00
{
print_liste_field_titre($langs->trans("Entity"),$_SERVER["PHP_SELF"],"g.entity",$param,"",'align="center"',$sortfield,$sortorder);
}
2011-02-12 00:39:21 +01:00
print_liste_field_titre($langs->trans("NbOfUsers"),$_SERVER["PHP_SELF"],"g.nb",$param,"",'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("DateCreation"),$_SERVER["PHP_SELF"],"g.datec",$param,"",'align="right"',$sortfield,$sortorder);
print "</tr>\n";
$var=True;
while ($i < $num)
2005-01-27 16:55:40 +01:00
{
$obj = $db->fetch_object($resql);
$var=!$var;
2013-06-20 09:18:12 +02:00
print "<tr ".$bc[$var].">";
print '<td><a href="fiche.php?id='.$obj->rowid.'">'.img_object($langs->trans("ShowGroup"),"group").' '.$obj->nom.'</a>';
if (! $obj->entity)
{
print img_picto($langs->trans("GlobalGroup"),'redstar');
}
print "</td>";
2011-08-19 09:22:17 +02:00
//multicompany
if (! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode) && $conf->entity == 1)
2011-08-19 09:22:17 +02:00
{
$mc->getInfo($obj->entity);
print '<td align="center">'.$mc->label.'</td>';
}
2011-02-12 00:39:21 +01:00
print '<td align="center">'.$obj->nb.'</td>';
print '<td align="right" class="nowrap">'.dol_print_date($db->jdate($obj->datec),"dayhour").'</td>';
print "</tr>\n";
$i++;
2005-01-27 16:55:40 +01:00
}
print "</table>";
$db->free();
}
else
{
dol_print_error($db);
2005-01-27 16:55:40 +01:00
}
llxFooter();
$db->close();
2005-01-27 16:55:40 +01:00
?>