<?php
!defined('IN_ONEZ') && exit('Access Denied');

$action=onez()->gp('action');
$record=$G['this']->data()->open('order')->page("1 order by id desc");
?>
<div class="panel panel-primary" style="margin-bottom: 0">
	<div class="panel-heading">支付记录</div>
  <table class="table table-striped">
    <thead>
      <tr>
        <th>订单号</th>
        <th>商品名称</th>
        <th>支付时间</th>
        <th>支付金额</th>
        <th>用户</th>
        <th>类型</th>
      </tr>
    </thead>
    <tbody class="todo-list">
      <?php foreach($record[0] as $rs){
        $u=$G['this']->data()->open('member')->one("id='$rs[userid]'"); ?>
      <tr>
        <td><?=$rs['orderno']?></td>
        <td><?=$rs['subject']?></td>
        <td><?=date('Y-m-d H:i:s',$rs['addtime'])?></td>
        <td><?=$rs['price']?></td>
        <td><img src="<?=$G['this']->avatar($rs['userid'])?>" style="width:16px;height:16px;position: relative;top: -2px;" /> <?=$u['nickname']?> (<?=$u['key2']?>)</td>
        <td><?=$G['this']->paytype($rs['postdata']['paytype'])?></td>
      </tr>
      <?php }?>
    </tbody>
  </table>
</div>
<?=$record[1]?>

<script type="text/javascript">
function _status(){
  var num=0;
  $('[data-status]').each(function(){
    var status=$(this).attr('data-status');
    var id=$(this).attr('data-id');
    if(status!='setup' && status!='zip'){
      num++;
      $.post(window.location.href,{action:'status',id:id,status:status},function(data){
        if(data.change){
          $('[data-id="'+data.id+'"]').attr('data-status',data.status).html(data.html);
        }
      },'json');
    }
  });
  if(num>0){
    setTimeout('_status()',2000);
  }
}
_status();
</script>