Fix to limit count based on u/g, also use class to get_list()

This commit is contained in:
Miles Lott 2001-03-26 21:12:56 +00:00
parent 501f75b630
commit 5f06d2940e
2 changed files with 85 additions and 77 deletions

View File

@ -14,24 +14,23 @@
$phpgw_info = array();
$phpgw_info['flags'] = array('currentapp' => 'admin', 'enable_nextmatchs_class' => True);
include('../header.inc.php');
// include(PHPGW_APP_INC . '/accounts_' . $phpgw_info['server']['account_repository'] . '.inc.php');
// include(PHPGW_APP_INC . '/accounts_' . $phpgw_info['server']['account_repository'] . '.inc.php');
function account_total($query)
{
global $phpgw;
if ($query) {
$querymethod = " where account_firstname like '%$query%' OR account_lastname like "
. "'%$query%' OR account_lid like '%$query%' ";
$querymethod = " AND (account_firstname LIKE '%$query%' OR account_lastname LIKE "
. "'%$query%' OR account_lid LIKE '%$query%') ";
}
$phpgw->db->query('select count(*) from phpgw_accounts'.$querymethod,__LINE__,__FILE__);
$phpgw->db->query("SELECT COUNT(*) FROM phpgw_accounts WHERE account_type='u'".$querymethod,__LINE__,__FILE__);
$phpgw->db->next_record();
return $phpgw->db->f(0);
}
$p = CreateObject('phpgwapi.Template',$phpgw->common->get_tpl_dir('admin'));
$p->set_file(array(
@ -57,7 +56,7 @@
$p->set_var('lang_delete',lang('Delete'));
$p->set_var('lang_view',lang('View'));
$account_info = $phpgw->accounts->get_list('accounts',$start,$sort, $order, $query);
$account_info = $phpgw->accounts->get_list('accounts',$start,$sort, $order, $query, $total);
if (! count($account_info))
{
@ -66,10 +65,8 @@
}
else
{
while (list($null,$account) = each($account_info))
{
$lastname = $account['account_lastname'];
$firstname = $account['account_firstname'];
$account_id = $account['account_id'];

View File

@ -15,55 +15,66 @@
$phpgw_info["flags"] = array("currentapp" => "admin", "enable_nextmatchs_class" => True);
include("../header.inc.php");
$p = CreateObject('phpgwapi.Template',$phpgw->common->get_tpl_dir('admin'));
$p->set_file(array("list" => "groups.tpl",
"row" => "groups_row.tpl"));
if (! $start)
$start = 0;
if ($order)
$ordermethod = "ORDER BY $order $sort";
else
$ordermethod = "ORDER BY account_lid asc";
if (! $sort)
$sort = "asc";
function account_total($query)
{
global $phpgw;
if ($query) {
$querymethod = "AND account_lid like '%$query%'";
$querymethod = " AND account_firstname LIKE '%$query%' OR account_lastname LIKE "
. "'%$query%' OR account_lid LIKE '%$query%' ";
}
$phpgw->db->query("SELECT count(*) FROM phpgw_accounts WHERE account_type='g' $querymethod");
$phpgw->db->query("SELECT COUNT(*) FROM phpgw_accounts WHERE account_type='g'".$querymethod,__LINE__,__FILE__);
$phpgw->db->next_record();
$total = $phpgw->db->f(0);
$limit = $phpgw->db->limit($start,$total);
return $phpgw->db->f(0);
}
$p = CreateObject('phpgwapi.Template',$phpgw->common->get_tpl_dir('admin'));
$p->set_file(array(
'list' => 'groups.tpl',
'row' => 'groups_row.tpl',
'empty_row' => 'accounts_row_empty.tpl'
));
$account_info = $phpgw->accounts->get_list('groups',$start,$sort, $order, $query, $total);
$total = account_total($query);
$p->set_var("th_bg",$phpgw_info["theme"]["th_bg"]);
$p->set_var("left_nextmatchs",$phpgw->nextmatchs->left("groups.php",$start,$total));
$p->set_var("right_nextmatchs",$phpgw->nextmatchs->right("groups.php",$start,$total));
$p->set_var("left_nextmatchs",$phpgw->nextmatchs->left("/admin/groups.php",$start,$total));
$p->set_var("right_nextmatchs",$phpgw->nextmatchs->right("/admin/groups.php",$start,$total));
$p->set_var("lang_groups",lang("user groups"));
$p->set_var("sort_name",$phpgw->nextmatchs->show_sort_order($sort,"account_lid",$order,"groups.php",lang("name")));
$p->set_var("header_edit",lang("Edit"));
$p->set_var("header_delete",lang("Delete"));
$phpgw->db->query("SELECT * FROM phpgw_accounts WHERE account_type='g' $querymethod $ordermethod $limit");
while ($phpgw->db->next_record()) {
$account_info = $phpgw->accounts->get_list('groups',$start,$sort, $order, $query, $total);
if (! count($account_info))
{
$p->set_var('message',lang('No matchs found'));
$p->parse('rows','empty_row',True);
}
else
{
while (list($null,$account) = each($account_info))
{
$account_id = $account['account_id'];
$group_name = $account['account_lid'];
$tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
$p->set_var("tr_color",$tr_color);
$group_name = $phpgw->db->f("account_lid");
if (! $group_name) $group_name = ' ';
$p->set_var("group_name",$group_name);
$p->set_var("edit_link",'<a href="' . $phpgw->link("/admin/editgroup.php","group_id=" . $phpgw->db->f("account_id")) . '"> ' . lang("Edit") . ' </a>');
$p->set_var("delete_link",'<a href="' . $phpgw->link("/admin/deletegroup.php","group_id=" . $phpgw->db->f("account_id")) . '"> ' . lang("Delete") . ' </a>');
$p->set_var("edit_link",'<a href="' . $phpgw->link("/admin/editgroup.php","group_id=" . $group_id) . '"> ' . lang("Edit") . ' </a>');
$p->set_var("delete_link",'<a href="' . $phpgw->link("/admin/deletegroup.php","group_id=" . $group_id) . '"> ' . lang("Delete") . ' </a>');
$p->parse("rows","row",True);
}
}
$p->set_var("new_action",$phpgw->link("/admin/newgroup.php"));