<?php
/**
 * 补领订单列表
**/
include("../php/common.php");
$title='补领订单列表';
include './head.php';
if($islogin==1){}else exit("<script language='javascript'>window.location.href='./login.php';</script>");
?>
  <nav class="navbar navbar-fixed-top navbar-default">
    <div class="container">
      <div class="navbar-header">
        <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
          <span class="sr-only">导航按钮</span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
        </button>
        <a class="navbar-brand" href="./">后台管理</a>
      </div><!-- /.navbar-header -->
      <div id="navbar" class="collapse navbar-collapse">
        <ul class="nav navbar-nav navbar-right">
          <li>
            <a href="./"><span class="glyphicon glyphicon-user"></span> 平台首页</a>
          </li>
		  <li>
            <a href="./list.php"><span class="glyphicon glyphicon-list"></span> 代点列表</a>
          </li>
		  <li class="active">
            <a href="./bllist.php"><span class="glyphicon glyphicon-calendar"></span> 补领列表</a>
          </li>
		  <li>
            <a href="#" class="dropdown-toggle" data-toggle="dropdown"><span class="glyphicon glyphicon-cloud"></span> 卡密管理<b class="caret"></b></a>
            <ul class="dropdown-menu">
              <li><a href="./kmlist.php">卡密列表</a></li>
			  <li><a href="./search.php">搜索卡密</a><li>
            </ul>
          </li>
		  <li><a href="./set.php"><span class="glyphicon glyphicon-cog"></span> 系统设置</a></li>
          <li><a href="./login.php?logout"><span class="glyphicon glyphicon-log-out"></span> 退出登陆</a></li>
        </ul>
      </div><!-- /.navbar-collapse -->
    </div><!-- /.container -->
  </nav><!-- /.navbar -->
  <div class="container" style="padding-top:70px;">
    <div class="col-sm-12 col-md-10 center-block" style="float: none;">
<?php
function display_zt($zt){
	if($zt==1)
		return '<font color=blue>待发货</font>';
	elseif($zt==2)
		return '<font color=red>密码错误</font>';
	elseif($zt==3)
		return '<font color=yellow>处理中</font>';
	elseif($zt==4)
		return '<font color=green>已完成</font>';
}

$numrows=$DB->count("SELECT count(*) from qiu_shop");
$ondate=$DB->count("select count(*) from qiu_shop where zt=4");
echo '<div class="alert alert-info">系统共有'.$numrows.'个补领棒棒糖订单，其中已完成的有'.$ondate.'个。';
echo '</div>';

echo $con;
?>
      <div class="table-responsive">
        <table class="table table-striped">
          <thead><tr><th>用户名</th><th>密码</th><th>数量</th><th>添加时间</th><th>状态</th><th>操作</th></tr></thead>
          <tbody>
<?php
$pagesize=30;
$pages=intval($numrows/$pagesize);
if ($numrows%$pagesize)
{
 $pages++;
 }
if (isset($_GET['page'])){
$page=intval($_GET['page']);
}
else{
$page=1;
}
$offset=$pagesize*($page - 1);

$rs=$DB->query("SELECT * FROM qiu_shop WHERE 1 order by id desc limit $offset,$pagesize");
while($res = $DB->fetch($rs))
{
echo '<tr><td><b>'.$res['user'].'</b></td><td>'.$res['pwd'].'</td><td>'.$res['value'].'</td><td>'.$res['addtime'].'</td><td>'.display_zt($res['zt']).'</td><td><select onChange="javascript:setStatus(\''.$res['id'].'\',this.value)" class="form-control"><option selected>操作订单</option><option value="1">待发货</option><option value="3">处理中</option><option value="4">已完成</option><option value="2">密码错误</option><option value="5">删除订单</option></select></td></tr>';
}
?>
          </tbody>
        </table>
      </div>
<?php
echo'<ul class="pagination">';
$first=1;
$prev=$page-1;
$next=$page+1;
$last=$pages;
if ($page>1)
{
echo '<li><a href="bllist.php?page='.$first.$link.'">首页</a></li>';
echo '<li><a href="bllist.php?page='.$prev.$link.'">&laquo;</a></li>';
} else {
echo '<li class="disabled"><a>首页</a></li>';
echo '<li class="disabled"><a>&laquo;</a></li>';
}
for ($i=1;$i<$page;$i++)
echo '<li><a href="bllist.php?page='.$i.$link.'">'.$i .'</a></li>';
echo '<li class="disabled"><a>'.$page.'</a></li>';
for ($i=$page+1;$i<=$pages;$i++)
echo '<li><a href="bllist.php?page='.$i.$link.'">'.$i .'</a></li>';
echo '';
if ($page<$pages)
{
echo '<li><a href="bllist.php?page='.$next.$link.'">&raquo;</a></li>';
echo '<li><a href="bllist.php?page='.$last.$link.'">尾页</a></li>';
} else {
echo '<li class="disabled"><a>&raquo;</a></li>';
echo '<li class="disabled"><a>尾页</a></li>';
}
echo'</ul>';
#分页
?>
    </div>
  </div>
<script>
function setStatus(name, status) {
	$.ajax({
		type : 'get',
		url : 'setStatus.php',
		data : 'name=' + name + '&status=' + status,
		dataType : 'json',
		success : function(ret) {
			if (ret['code'] != 200) {
				return alert(ret['msg'] ? ret['msg'] : '操作失败');
			}
			window.location.reload();
		}
	});
}
</script>
<script src="../assets/datepicker/WdatePicker.js"></script>