<?php
$conf_basedir	= "../../";	//相对主目录的位置
$conf_where		= "admin";	//选择调用相应模块
include_once($conf_basedir."base.inc.php");
checkAuth('4');	//判断登录和权限
$title = "用户管理";
$js = "<script src= \" ".$conf_basedir."script/js/list_common.js\"></script>";

$ordercond = '';
$wherecond = ' uid > 1';

//设定查询条件
switch ($cond_search){
	case "username":
		$wherecond .= " AND username LIKE '%".$cond_value."%' ";
		break;
	case "truename":
		$wherecond .= " AND truename LIKE '%".$cond_value."%' ";
		break;
	default:
		break;
}

if($cond1_search)
{
	$wherecond .= " AND groupid = '".$cond1_search."' ";
}

if($cond2_search)
{
	$wherecond .= " AND status = '".($cond2_search - 1)."' ";
}

if($cond_order == ''){$cond_order = "username";}
if($cond_orderby == ''){$cond_orderby = "asc";}

$ordercond = " ORDER BY ".$cond_order." ".$cond_orderby;

$wherecond = $wherecond == '' ? 1 : $wherecond;

//分页参数
$pagesize   = $display_rows = $display_rows ? intval($display_rows) : 20;
$page_now	= $page_now ? max(1, intval($page_now)) : 1; // 获取当前页数
$offset		= ( $page_now - 1 ) * $pagesize;
//获得数据总条数
$sql = " SELECT COUNT(*) FROM admin_user WHERE  ".$wherecond ;
$numrows = $dbback_sys->GetOne($sql);
//获得数据当前页面数据
$sql = " SELECT * FROM admin_user WHERE ".$wherecond." ".$ordercond." LIMIT ".$offset.",".$pagesize." ";
//echo $sql;
$data_info = $dbback_sys->GetAll($sql);

$pagenum = count($data_info);//当前页面数量
$numrows = $numrows >0 ? $numrows : 0;

if( $numrows <= 0 || $pagenum <=0){
	$pages = 0 ;  //计算总页数
}else{
	$pages = ceil($numrows/$pagesize) ;  //计算总页数

	$new_pagenavi = new_pagenavi($page_now,$pages,$numrows);
}

$condarr = array(""=>"*请选择*");
$house['cond'] = array("username" =>"登录名","truename" =>"用户姓名");
$cond_search = tonyForm("select","cond_search",$condarr + $house['cond'],$cond_search);
$cond2_search = tonyForm("select","cond2_search",$condarr + array(1=>"无效账号",2=>"有效账号"),$cond2_search);
$cond_order = tonyForm("select","cond_order",$house['cond'],$cond_order);
$cond_orderby = tonyForm("select","cond_orderby",array("asc"=>"正序排列","desc"=>"逆序排列"),$cond_orderby);
$cond_page = tonyForm("select","display_rows",array("20"=>"20","30"=>"30"),$display_rows);

//引用模版文件
include_once(Template("header"));
include_once(Template("manage/auth_manage"));
include_once(Template("footer"));
?>