<?php
require_once("../check.php");
require_once("../../config.php");
ini_set("date.timezone",'PRC');
$m="12";//每页显示的记录数
isset($_GET['page'])?$page=$_GET['page']:$page="1";//当前页数
$numsql = "select count(id) as num from dunling_renwu";
$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_renwu 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>
<script src="../date/jquery.cxcalendar.js"></script>
<link rel="stylesheet" href="../date/jquery.cxcalendar.css"/>
</head>
<body>
<script>
$(function(){
    $(".chakan").click(function(){
    var title = $(this).parent().find(".title").text();
    var content = $(this).parent().find(".content").html();
    $("#title").val(title);
    $("#content").val(content);
    $("#windows").show();
    });
    
    $(".close").click(function(){
    $("#windows").hide();
    $("#title").val('');
    $("#content").val('');
    });
    
    $(".del").click(function(){
    var id = $(this).parent().attr("class");
    var danhao = $(this).parent().find(".danhao").text();
    var delok = confirm('确定删除编号为 '+ danhao +' 的任务吗？');
    if(delok==true){
    $.post("../core/delrw2.php",{
        id:id
    },function(aaa,bbb){
      $("."+id).remove();
    });
    }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:35px;
}
#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:600px;
    height:450px;
    left:0;
    border-radius:8px;
    position: absolute;
    margin-top:100px;
    margin-left:300px;

}
#windows .close{
    width:48px;
    height:48px;
    display: table;
    background-image:url("../images/close.png");
    position: absolute;
    margin-left:602px;
    margin-top:-10px;
    
}

.daterili{
    width:120px;
    height:20px;
    line-height:20px;
    text-align:center;
    color: green;
    font-weight:bold;
    background:url(../date/cxcalendar.png) no-repeat right;
}
#so{
    height:30px;
    line-height:30px;
    font-size:14px;
    color: red;
    margin-left:20px;
}
#form{
    margin:0;
    padding:0;
}
a{
    text-decoration:none;
    color:red;
}
#title{
    width:580px;
    height:30px;
    line-height:30px;
    font-size:14px;
    color: #575757;
    border:1px solid #9C9C9C;
    background-color: #F0F0F0;
}
#content{
    width:580px;
    height:350px;
    line-height:25px;
    font-size:14px;
    color: #575757;
    resize:none;
    border:1px solid #9C9C9C;
    background-color: #F0F0F0;
}
</style>
<div id="windows">
<div class="close" title="点击关闭"></div>
<div style="height:50px;text-align:center;"><input type="text" id="title" /></div>
<div style="text-align:center;"><textarea id="content"></textarea></div>
</div>


<div id="table">
<div class="W50"></div>
<div class="W150"><strong>发布人账号</strong></div>
<div class="W150"><strong>任务编号</strong></div>
<div class="W100"><strong>悬赏单价</strong></div>
<div class="W100"><strong>悬赏总额</strong></div>
<div class="W100"><strong>剩余金币</strong></div>
<div class="W100"><strong>是否截图</strong></div>
<div class="W150"><strong>发布时间</strong></div>
<div class="W100"><strong>详情</strong></div>
<div class="W100"><strong>操作</strong></div>
</div>
<?php
while($list = mysql_fetch_array($articleery)){
?>
<div id="table" class="<?php echo $list['id'];?>">
<div class="title" style="display: none;"><?php echo $list['title'];?></div>
<div class="content" style="display: none;"><?php echo str_replace("<br/>","\n",$list['content']);?></div>
<div class="W50"></div>
<div class="W150"><?php echo $list['username'];?></div>
<div class="W150 danhao"><?php echo $list['danhao'];?></div>
<div class="W100"><?php echo $list['danjia'];?></div>
<div class="W100"><?php echo $list['zmoney'];?></div>
<div class="W100"><?php echo $list['smoney'];?></div>
<div class="W100"><?php $img = $list['img'];
if($img=="1"){
    echo '是';
}else{
    echo "否";
}?></div>
<div class="W150"><?php echo date("m-d H:i",$list['datetime']);?></div>
<div class="W100 chakan" style="text-align: left;">查看</div>
<div class="W100 del">删除</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>
<script>
$(function(){
    $('#date1').cxCalendar();
    $('#date2').cxCalendar();
});
</script>
</body>