<?php
require_once("../check.php");
require_once("../../config.php");

$m="12";//每页显示的记录数
isset($_GET['page'])?$page=$_GET['page']:$page="1";//当前页数
isset($_GET['unions'])?$unions=$_GET['unions']:$unions=null;//当前页数




$numsql = "select count(id) as num from dunling_menber where unions='$unions'";
$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_menber where unions='$unions' 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(){
    
    
    $(".info").click(function(){
    var id = $(this).parent().find(".id").text();
    var username = $(this).text();
    var name = $(this).parent().find(".name").text();
    var alipay = $(this).parent().find(".alipay").text();
    var unions = $(this).parent().find(".unions").text();
    var money = $(this).parent().find(".moneypay").text();
    $(".a0").text(username);
    $(".new_name").val(name);
    $(".new_alipay").val(alipay);
    $(".new_union").val(unions);
    $(".new_money").val(money);
    $(".idz").val(id);
    $("#windows").fadeTo("slow", 0.90);
    
        
});

    $("#windows .close").click(function(){
        $("#windows").fadeOut("slow");
       
        
    });
    
     $("#form").click(function(){
        var username = $(".a0").text();
        var newname = $(".new_name").val();
        var newmoney = $(".new_money").val();
        var newalipay = $(".new_alipay").val();
        var newunion = $(".new_union").val();
        var idz = $(".idz").val();
        
        if( newname=="" || newmoney=="" || newalipay==""){
            alert('除推荐人以外，必须填写完整!');
            return false;
        }
    $("#" + idz).parent().find(".moneypay").text(newmoney);
        $.post("../core/update_user.php",{
            username:username,
            money:newmoney,
            name:newname,
            alipay:newalipay,
            union:newunion
        },function(aaa,bbb){
            if(aaa=="ok"){
          alert('修改完成!');
          
          return false;
          }else{
            alert("error");
          }
        

        });
        
    });
    
    
    
    
       
    $(".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{
    margin-left:20px;
    width:auto;
    max-width:1000px;
    min-height:35px;
    height:auto;
    display: table;
    line-height:35px;
    text-align:left;
    color: #505050;
    border-bottom:1px dashed #C9C9C9;
    font-size:14px;
}
#table:hover{
    background-color: #DDEEFF;
}
#table .id{
    width:60px;
    height:35px;
    line-height:35px;
    text-align:center;
    float:left;
}
#table .username{
    width:100px;
    height:35px;
    line-height:35px;
    text-align:left;
    float:left;
}
#table .moneypay{
    width:100px;
    height:35px;
    line-height:35px;
    text-align:center;
    float:left;
}
#table .money{
    width:100px;
    height:35px;
    line-height:35px;
    text-align:center;
    float:left;
}

#table .logintime{
    width:80px;
    height:35px;
    line-height:35px;
    text-align:center;
    float:left;
}
#table .nicheng{
    width:150px;
    height:35px;
    line-height:35px;
    text-align:center;
    float:left;
}

#table .ticheng{
    width:100px;
    height:35px;
    line-height:35px;
    text-align:center;
    float:left;
}

#table .unions{
    width:100px;
    height:35px;
    line-height:35px;
    text-align:center;
    float:left;
}
#table .caozuo{
    width:160px;
    height:35px;
    line-height:35px;
    text-align:center;
    float:left;
}
#table .name,.alipay{
    display:none;
}
.del{
    color: #00791F;
}
.del:hover{
    color: #FF4646;
    cursor:pointer;
}
.pass{
    color: #00791F;
}
.pass: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:280px;
    left:0;
    background-color: #F2F2F2;
    border:1px solid #D5D5D5;
    border-radius:8px;
    position: absolute;
    margin-top:100px;
    margin-left:250px;
    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;
    
}
</style>
<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="a0"></td></tr>
<tr><td align="right"><strong>收款人姓名:</strong></td><td class="a1"><input class="new_name" style="width: 300px;" /></td></tr>
<tr><td align="right"><strong>支付宝账号:</strong></td><td class="a2"><input class="new_alipay" style="width: 300px;" /></td></tr>
<tr><td align="right"><strong>可用余额:</strong></td><td class="a3"><input class="new_money" style="width: 300px;" /></td></tr>
<tr><td align="right"><strong>推荐人UID:</strong></td><td><input class="new_union" style="width: 300px;" /></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="id"><strong>ID</strong></div>
<div class="username"><strong>账号<span style="color: red;font-size:12px;">(单击修改)</span></strong></div>
<div class="nicheng"><strong>推荐下级</strong></div>
<div class="moneypay"><strong>可用余额</strong></div>
<div class="ticheng"><strong>下线提成</strong></div>
<div class="money"><strong>收益总计</strong></div>
<div class="unions"><strong>上线UID</strong></div>
<div class="logintime"><strong>最后登录</strong></div>
<div class="caozuo"><strong>操作</strong></div>
</div>
<?php
while($list = mysql_fetch_array($articleery)){
$id = $list['id'];
$username  = $list['username'];
$nicheng  = $list['nicheng'];
$moneypay = $list['moneypay'];
$money = $list['money'];
$unions = $list['unions'];
$logintime = $list['logintime'];
$logintime =  date("m-d H:i",$logintime);
$ticheng = $list['ticheng'];
$alipay = $list['alipay'];
$name = $list['name'];
?>
<div id="table">
<div id="<?php echo $id;?>" style="display: none;"></div>
<div class="alipay"><?php echo $alipay;?></div>
<div class="name"><?php echo $name;?></div>
<div class="id"><?php echo $id;?></div>
<div class="username info"><?php echo $username;?></div>
<div class="nicheng">

<?php
if($xiaxianrenshu>"0"){
echo '<a href="xiaxian.php?page=1&unions='.$id.'">查看</a>';
}else{
    echo "无";
}
?>

</div>
<div class="moneypay"><?php echo $moneypay;?></div>
<div class="ticheng"><?php echo $ticheng;?></div>
<div class="money"><?php echo $money;?></div>
<div class="unions"><?php echo $unions;?></div>
<div class="logintime"><?php echo $logintime;?></div>
<div class="caozuo"><span class="del">删除</span> <span class="pass">重置密码</span></div>
</div>
<?
}
?>
<div id="p">
<div class="page">
<?php
$shangyiye = $page-"1"."&unions=".$unions;
$xiayiye = $page+"1"."&unions=".$unions;
if($page>"1"){
        echo '<li><a href="?page='.$shangyiye.'">上一页</a></li>';
        echo '<li><a href="?page=1&unions='.$unions.'">1</a></li>';
}
if($page>="6"){
for($pagea=$page-4;$pagea<=$page-1;$pagea++){
        echo '<li><a href="?page='.$pagea.'&unions='.$unions.'">'.$pagea.'</a></li>';
}
}
echo '<li class="dangqianye"><a href="?page='.$page.'&unions='.$unions.'">'.$page.'</a></li>';

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

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

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