<?php include _include(APP_PATH.'view/htm/header.inc.htm');
if(empty($uid)) message(-1, '请先登录后再查看购买记录!');
$tid = param(2, 0); $page =  param(3, 1);
$_thread=db_find_one('thread',array('tid'=>$tid));
empty($_thread) AND message(-1, '主题不存在');
thread_format($_thread);
$data= db_find('paylist',array('tid'=>$tid),array('paytime'=>1), $page, $pagesize=20);
$list_count = db_count('paylist',array('tid'=>$tid));
$pagination = pagination(url("thread-sPay-{$tid}-{page}"), $list_count, $page, $pagesize=20);
function get_user($uid){
    $user = db_find_one('user',array('uid'=>$uid));
    return $user;
}
$is_rmb = $_thread['content_buy_type']=='3'? 1:0 ;
?>
<div class="row"><div class="col-lg-10 mx-auto"><div class="card"><div class="card-body" ><h4><?php echo lang("c_buy_record");?> - <?php echo $_thread['subject'];?></h4>
    <div style="margin-bottom:8px;"><a href="<?php echo url("user-$_thread[uid]");?>" class="mr-3" tabindex="-1"><img class="avatar-1" src="<?php echo $_thread['user']['avatar_url'];?>">&nbsp;<?php echo $_thread['user']['username'];?></a></div>
    <div class="input-group mb-3"><div class="input-group-prepend"><span class="input-group-text"><?php echo lang("c_num");?></span></div>
        <input type="text" class="form-control" readonly style="background-color: white;" value="<?php echo $list_count;?>"></div>
    <div class="input-group mb-3"><div class="input-group-prepend"><span class="input-group-text"><?php echo lang("credits");?></span></div>
        <input type="text" class="form-control" readonly style="background-color: white;" value="<?php echo ($is_rmb? $_thread['content_buy']/100.0 : $_thread['content_buy']) .' '.lang('credits'.$_thread['content_buy_type']);?>"></div>
</div></div><div class="card"><div class="card-body">
<table class="table"><tr><th style="width:30%;"><?php echo lang("c_time");?></th><th style="width:70%;"><?php echo lang("c_user");?></th></tr>
    <?php foreach($data as $v){$__user = get_user($v['uid']);user_format($__user); ?>
    <tr style="<?php echo $v['uid']==$uid?'font-weight:bold;':'';?>"><td><?php echo date('Y-m-d H:i:s',$v['paytime']);?></td><td><a href="<?php echo url("user-$v[uid]");?>" class="mr-3" tabindex="-1"><img class="avatar-1" src="<?php echo $__user['avatar_url'];?>"></a>&nbsp;<a href="<?php echo url("user-$v[uid]");?>" class="mr-3" tabindex="-1"><?php echo $__user['username'];?></a></td>
    </tr><?php }?></table>
    <nav class="text-center"><ul class="pagination"><?php echo $pagination; ?></ul></nav>
</div></div></div></div>
<?php include _include(APP_PATH.'view/htm/footer.inc.htm');?>