<?php
session_start();
require_once "../init.php";
require_once "../authority.inc.php";

$iStatus = $_GET['iStatus'];
$daili = $_GET['daili'];
$keyword = $_POST['keyword'];

$backUrl = GetUrl();

$keyword=trim($keyword);
if($keyword){
	$wheres=" AND (UserName like '%$keyword%' or Contact_GB like '%$keyword%' or Company_GB like '%$keyword%') ";
}
if($iStatus!="")$wheres .= " AND iStatus = '$iStatus'";
if(is_numeric($daili))$wheres .= " and iLevel='".$daili."'";
/*** 得到总记录数 *************/
$sql = "select count(*) from users where 1 $wheres";
$rs  = $DB->query($sql);
$pageSize = 30;
$totalRecord = $DB->result($rs,0,0);
$totalPage   = ceil($totalRecord/$pageSize);
if(!$page)$page = 1;
$offset = ($page-1)*$pageSize;
/*** 查询 *************/
$sql = "SELECT * FROM users WHERE 1 $wheres ORDER BY dtCreate DESC LIMIT $offset,$pageSize";
$result = $DB->query($sql);
$pageList = GetPageList($_SERVER[PHP_SELF],"page","15",$totalPage,$page);
$PNum = $DB->num_rows($result);
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">


<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<LINK rel="Bookmark" href="/favicon.ico" >
<LINK rel="Shortcut Icon" href="/favicon.ico" />

<!--[if lt IE 9]>
<script type="text/javascript" src="/admin/lib/html5.js"></script>
<script type="text/javascript" src="/admin/lib/respond.min.js"></script>
<script type="text/javascript" src="../lib/PIE_IE678.js"></script>
<![endif]-->
<link rel="stylesheet" type="text/css" href="/admin/static/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="/admin/static/h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="/admin/lib/Hui-iconfont/1.0.7/iconfont.css" />
<link rel="stylesheet" type="text/css" href="/admin/lib/icheck/icheck.css" />
<link rel="stylesheet" type="text/css" href="/admin/static/h-ui.admin/skin/default/skin.css" id="skin" />
<link rel="stylesheet" type="text/css" href="/admin/static/h-ui.admin/css/style.css" />
<!--[if IE 6]>
<script type="text/javascript" src="admin/static/h-ui.admin/js/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<!--/meta 作为公共模版分离出去-->
<title>会员管理</title>

<script src='../share/global.js'></script>
</head>
<body>

<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 会员管理 <span class="c-gray en">&gt;</span> 会员列表<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>


<div class="page-container">
<!--子导航-->
<? include "user_nav.inc.php"?>
<!--结束-->
<br>
<!--搜索-->
<form method='post' action='<?=$_SERVER['PHP_SELF']?>'>

<div class="text-c"> 日期范围：
		<input type="text" onfocus="WdatePicker({maxDate:'#F{$dp.$D(\'datemax\')||\'%y-%M-%d\'}'})" id="datemin" class="input-text Wdate" style="width:120px;">
		-
		<input type="text" onfocus="WdatePicker({minDate:'#F{$dp.$D(\'datemin\')}',maxDate:'%y-%M-%d'})" id="datemax" class="input-text Wdate" style="width:120px;">
		<input type="text" name="keyword"  onfocus="WdatePicker({maxDate:'#F{$dp.$D(\'datemax\')||\'%y-%M-%d\'}'})" class="input-text" style="width:250px" placeholder="输入定单" id="" name="">
		<button type="submit" class="btn btn-success" id="" name=""><i class="Hui-iconfont">&#xe665;</i> 搜用户</button>
	</div>
</form>
<!--搜索-->
<div id="page">
<?
	$pageStr="共 $totalRecord 条记录,共 $totalPage 页,当前第 $page 页";
	echo $pageStr;
?>
</div>
<?if($PNum){?>
<div>
      <table  border="0" cellspacing="0" cellpadding="0" class="table table-border table-bordered table-hover table-bg table-sort">
        <tr id="tr">
		  <td><input type="checkbox" class="checkbox"></td>
          <td>用户名</td>
		  <td>状态</td>
          <td>联系人</td>
          <td>会员级别</td>
		  <td>公司名</td>
		  <td>电话</td>
          <td>E-Mail</td>
          <td>最后登录</td>
          <td>操作</td>
        </tr>
        <? while($UserInfo=$DB->fetch_array($result)){?>
		<? $key = GetHashKey('users'.$UserInfo[UserName]);?>
        <tr bgcolor='#ffffff' onmouseover='inStyle(this)' onmouseout='outStyle(this)' id="td">
		 <td><input type="checkbox" class="checkbox"></td>
          <td><a href="user_edit.php?UserName=<?=$UserInfo[UserName]?>&key=<?=$key?>&backUrl=<?=$backUrl?>">
		  <?=$UserInfo[UserName]?></a> 
		  </td>
		  <td><?=$UserInfo[iStatus]?"<span style='color:green'>正常</span>":"<span style='color:red'>被禁用</span>"?></td>
          <td><?=$UserInfo[Contact_GB]?></td>
          <td><?=$UserInfo[iLevel]>0?$UserLevel[$UserInfo[iLevel]]?"<span class='eng'> ".$UserLevel[$UserInfo[iLevel]]." </span>":"<span class='eng'> $UserInfo[iLevel] </span> 级代理":"普通会员"?></td>
		  <td style="text-align:left"><?=$UserInfo[Company_GB]?></td>
		  <td><?=$UserInfo[Tel]?></td>
          <td><?=$UserInfo[Email]?></td>
          <td><?=$UserInfo[dtLogin]?></td>
          <td> 
			<a href="login.php?UserName=<?=$UserInfo[UserName]?>" target="_blank">登陆</a> |
			<a href="user_edit.php?UserName=<?=$UserInfo[UserName]?>&key=<?=$key?>&backUrl=<?=$backUrl?>">详细</a> |
            <a href="user_del.php?UserName=<?=$UserInfo[UserName]?>&key=<?=$key?>&backUrl=<?=$backUrl?>" onClick="return confirm('确定删除吗?')">删除</a> |
			<a href="../financial/financial_user_record.php?UserName=<?=$UserInfo[UserName]?>&key=<?=$key?>">财务记录</a>
		  </td>
        </tr>
        <? }?>
      </table>
</div>
<div id="page">
<? echo $pageStr;?>
</div>
<center>
<?
  if($pageList) echo "$pageList[0] <br> $pageList[1]";
?>
</center>
<?	}else{
	   echo "<center><br><br>没有相关记录<br><br></center>";
	}
?>
</div>
<? 
$DB->close();
include "../share/bottom.php";
?>
</body>
</html>
