<?php
require_once("../check.php");
require_once("../../config.php");
$m="12";//每页显示的记录数
isset($_GET['wd'])?$wd=$_GET['wd']:$wd=null;//当前关键词
$where = null;
if($wd!=null){
    
    $where = "where username='$wd' or id='$wd'";
    
}
isset($_GET['page'])?$page=$_GET['page']:$page="1";//当前页数
$numsql = "select count(id) as num from dunling_user $where";
$numery = mysql_query($numsql,$config);
$numery = mysql_fetch_array($numery);
$zongjilushu = $numery['num'];//总记录数
$zy = (int)(($zongjilushu-1)/$m)+1;//总页数
$one = (int)($page-1)*$m;//当前页的首条记录
$articlesql = "select * from dunling_user $where order by id desc limit $one,$m";
$articleery = mysql_query($articlesql,$config);
?>
<!DOCTYPE HTML>
<html>
<head>
<title>用户管理</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<script src="../js/jquery-1.11.1.min.js"></script>
</head>
<body>
<script>
$(function(){
    
    
    $(".close").click(function(){
        $("#windows").hide();
    });
    
    $(".update").click(function(){
    var id = $(this).parent().parent().find(".id").text();
    var username = $(this).parent().parent().find(".username").text();
    var qq = $(this).parent().parent().find(".qq").val();
    var money = $(this).parent().parent().find(".money").text();
    var zmoney = $(this).parent().parent().find(".zmoney").text();
    var jinbi = $(this).parent().parent().find(".jinbi").text();
    var pay1 = $(this).parent().parent().find(".pay1").val();
    var pay2 = $(this).parent().parent().find(".pay2").val();
    var pay3 = $(this).parent().parent().find(".pay3").val();
    $(".idz").val(id);
    $(".u0").text(username);
    $(".u1").val(zmoney);
    $(".u2").val(money);
    $(".u3").val(jinbi);
    $(".u4").val(pay3);
    $(".u5").val(pay2);
    $(".u6").val(pay1);
    $(".u7").val(qq);
    $("#windows").show();
    });
    
    $("#form").click(function(){
        var id = $(".idz").val();
        var username = $(".u0").text();
        var zmoney = $(".u1").val();
        var money = $(".u2").val();
        var jinbi = $(".u3").val();
        var pay3 = $(".u4").val();
        var pay2 = $(".u5").val();
        var pay1 = $(".u6").val();
        var qq = $(".u7").val();
        var Atable = username+id;
        $.post("../core/update_user.php",{
            id:id,
            zmoney:zmoney,
            money:money,
            jinbi:jinbi,
            pay3:pay3,
            pay2:pay2,
            pay1:pay1,
            qq:qq
        },function(ab,ba){
            if(ab=="ok"){
                $("."+Atable).find(".money").text(money);
                $("."+Atable).find(".zmoney").text(zmoney);
                $("."+Atable).find(".jinbi").text(jinbi);
                $("."+Atable).find(".qq").val(qq);
                $("."+Atable).find(".pay1").val(pay1);
                $("."+Atable).find(".pay2").val(pay2);                
                $("."+Atable).find(".pay3").val(pay3);                
                alert('修改成功');
                $("#windows").hide();
            }
            
            
        });
        
    });

    $(".del").click(function(){
    var id = $(this).parent().parent().find(".id").text();
    var username = $(this).parent().parent().find(".username").text();
    var ok = confirm('确定删除会员 " ' + username + ' " 吗?');
        if(ok){
        $.get("../core/del_user.php?id=" + id,function(a,b){
        if(a=="ok"){
        alert('删除成功!');
        $(".id:contains(" + id + ")").parent().remove();
        return false;
        }else{
        alert('删除数据出现失败!');
        return false;    
        }
        });
    }else{
        return false;
    }

    });
    

    
    

    $(".pass").click(function(){
    var id = $(this).parent().parent().find(".id").text();
    var username = $(this).parent().parent().find(".username").text();
    var ok = confirm('确定重置 " ' + username + ' " 密码吗?');
        if(ok){
            $.post("../core/pass_reset.php",{
                username:username,
                id:id
            },function(a,b){
                alert('密码已重置为888888');
                return false;
            });
    }else{
        return false;
    }

    });

});

</script>
<style>
body{
    margin:0;
    padding:0;
    text-align:left;
}
#table{
    width:auto;
    width:100%;
    height:auto;
    min-height: 45px;
    display: table;
    text-align:center;
    color: #505050;

    font-size:14px;
}
#table:hover{
    background-color: #DDEEFF;

}
#table .W50{
    width:50px;
    height:40px;
    line-height:40px;
    text-align:left;
    float:left;
}
#table .W100{
    width:100px;
    height:40px;
    line-height:40px;
    text-align:left;
    float:left;
}

#table .W150{
    width:150px;
    height:40px;
    line-height:40px;
    text-align:left;
    float:left;
}

#table .W200{
    width:200px;
    height:40px;
    line-height:40px;
    text-align:center;
    float:left;
}

#table .W250{
    width:250px;
    height:40px;
    line-height:40px;
    text-align:left;
    float:left;
}
#table .W300{
    width:300px;
    height:40px;
    line-height:40px;
    text-align:left;
    float:left;
}
#table .W350{
    width:350px;
    height:40px;
    line-height:40px;
    text-align:left;
    float:left;
}

#table .W400{
    width:400px;
    height:40px;
    line-height:40px;
    text-align:left;
    float:left;
}

table tr td{
    line-height:40px;
}
span{
    color: #00791F;
    width:35px;
    height:35px;
}
span:hover{
    color: #FF4646;
    cursor:pointer;
}


#p{
    margin-top:25px;
    margin-left:20px;
    width:auto;
    max-width:950px;
    min-height:50px;
    height:auto;
    display: table;
    line-height:50px;
    text-align:left;
    color: #505050;
    font-size:14px;
}
#p .page{
    width:950px;
    height:50px;
    line-height:50px;
    text-align:right;
}

#p .page li{
    text-align:center;
    display:inline;
    margin:0 5px 0 0px;
    float:left;
    height:50px;
}


#p .page li a{
    border-radius:3px;
    text-decoration: none;
    font-size:14px;
    color:#08246B;
    display: block;
    line-height: 30px;
    height:30px;
    padding-left: 12px;
    padding-right:12px;
    border:1px solid #08246B;
    box-shadow:0px 0px 3px 3px #DFDFDF;
}
#p .page li a:hover{
    border-radius:3px;
    width:auto;
    text-decoration: none;
    font-size:14px;
    color:#FFFFFF;
    display:table;
    line-height: 30px;
    height:30px;
    padding-left: 12px;
    padding-right:12px;
    background-color:#08246B;
}
#p .page li.dangqianye a{
    border-radius:3px;
    text-decoration: none;
    font-size:14px;
    color:#FFFFFF;
    display: block;
    line-height: 30px;
    height:30px;
    width:auto;
    padding-left: 12px;
    padding-right:12px;
    border:1px solid #08246B;
    background-color: #08246B;
}
#windows{
    display: none;
    text-align:left;
    width:500px;
    height:425px;
    left:0;
    background-color: #F2F2F2;
    border:1px solid #D5D5D5;
    border-radius:8px;
    position: absolute;
    margin-top:35px;
    margin-left:350px;
    box-shadow:0px 0px 5px 5px #D5D5D5;
    color: #5E5E5E;
    font-size:14px;
}
#windows .close{
    width:48px;
    height:48px;
    display: table;
    background-image:url("../images/close.png");
    position: absolute;
    margin-left:505px;
    margin-top:-10px;
    
}
#so{
    height:30px;
    line-height:30px;
    font-size:14px;
    color: red;
    margin-left:20px;
}
#form{
    margin:0;
    padding:0;
}
#touxiang{
    width:60px;
    height:60px;
    border-radius:30px;
}
.u1,.u2,.u3,.u4,.u5,.u6,.u7,.u8{
    width:250px;
    height:25px;
    line-height:25px;
}
</style>
<div id="so"><form method="GET" action="user.php">输入ID或账号: <input name="wd" type="text" style="width: 100px;" /><input type="submit" value="搜索" /></form></div>
<div id="table">
<div id="windows">
<div class="close" title="点击关闭"></div>
<div>
<table cellpadding="1" cellspacing="2" align="center">
<input class="idz" value="" type="hidden" />
<tr><td align="right"><strong>用户账号:</strong></td><td class="u0"></td></tr>
<tr><td align="right"><strong>总共收益:</strong></td><td><input class="u1" /></td></tr>
<tr><td align="right"><strong>可用余额:</strong></td><td><input class="u2" /></td></tr>
<tr><td align="right"><strong>可用金币:</strong></td><td><input class="u3"/></td></tr>
<tr><td align="right"><strong>收款姓名:</strong></td><td class="a1"><input class="u4" /></td></tr>
<tr><td align="right"><strong>收款账号:</strong></td><td class="a2"><input class="u5"  /></td></tr>
<tr><td align="right"><strong>收款方式:</strong></td><td class="a3"><input class="u6"  /></td></tr>
<tr><td align="right"><strong>QQ号码:</strong></td><td><input class="u7"/></td></tr>
<tr><td align="right"></td><td><input id="form" style="width: 200px;height:33px;line-height:33px;" type="button" value="确认修改" /></td></tr>
</table>
</div>
</div>
<div class="W50"></div>
<div class="W50 id"><strong>ID</strong></div>
<div class="W200 username"><strong>账号</strong></div>
<div class="W150 money"><strong>余额(元)</strong></div>
<div class="W150 zmoney"><strong>总收益(元)</strong></div>
<div class="W150 jinbi"><strong>金币</strong></div>
<div class="W150"><strong>注册时间</strong></div>
<div class="W150"><strong>最后登录</strong></div>
<div class="W150"><strong>管理操作</strong></div>
</div>
<?php
while($list = mysql_fetch_array($articleery)){
$id = $list['id'];
$username  = $list['username'];
$money = $list['money'];
$zmoney = $list['zmoney'];
$regtime = $list['regtime'];
$regtime =  date("m-d H:i",$regtime);
$logintime = $list['logintime'];
$logintime =  date("m-d H:i",$logintime);
$jinbi = $list['jinbi'];
$qq = $list['qq'];
$pay1 =$list['pay1'];
$pay2 =$list['pay2'];
$pay3 =$list['pay3'];

?>
<div id="table" class="<?php echo $username.$id;?>">
<input type="hidden" value="<?php echo $qq;?>" class="qq" />
<input type="hidden" value="<?php echo $pay1;?>" class="pay1" />
<input type="hidden" value="<?php echo $pay2;?>" class="pay2" />
<input type="hidden" value="<?php echo $pay3;?>" class="pay3" />
<div class="W50"></div>
<div class="W50 id"><?php echo $id;?></div>
<div class="W200 username"><?php echo $username;?></div>
<div class="W150 money"><?php echo $money;?></div>
<div class="W150 zmoney"><?php echo $zmoney;?></div>
<div class="W150 jinbi"><?php echo $jinbi;?></div>
<div class="W150"><?php echo $regtime;?></div>
<div class="W150"><?php echo $logintime;?></div>
<div class="W150">
<span class="update">修改</span> <span class="del">删除</span> <span class="pass">重置密码</span>
</div>
</div>
<?php
}
?>
<div id="p">
<div class="page">
<?php
$shangyiye = $page-1;
$xiayiye = $page+1;
if($page>"1"){
        echo '<li><a href="?page='.$shangyiye.'">上一页</a></li>';
        echo '<li><a href="?page=1">1</a></li>';
}
if($page>="6"){
for($pagea=$page-4;$pagea<=$page-1;$pagea++){
        echo '<li><a href="?page='.$pagea.'">'.$pagea.'</a></li>';
}
}
echo '<li class="dangqianye"><a href="?page='.$page.'">'.$page.'</a></li>';

     
if(($zy-$page)>="5"){
for($pageb=$page+1;$pageb<=$page+4;$pageb++){
        echo '<li><a href="?page='.$pageb.'">'.$pageb.'</a></li>';
}
}

if("5">=($zy-$page)){
for($pagec=$page+1;$pagec<=$zy-1;$pagec++){
        echo '<li><a href="?page='.$pagec.'">'.$pagec.'</a></li>';
}
}

if($page<$zy){
        echo '<li><a href="?page='.$zy.'">..'.$zy.'</a></li>';
        echo '<li><a href="?page='.$xiayiye.'">下一页</a></li>';
}
?>
</div>
</div>
</body>