<?php
!defined('IN_ONEZ') && exit('Access Denied');
define('CUR_URL',onez('chat.group.plugin.credit')->href('/pages/log.php'));
include_once(dirname(__FILE__).'/init.php');


$G['title']='交易明细管理';
$action=onez()->gp('action');

$xxx="";
$kw=onez()->gp('kw');
if($kw){
  $_GET['kw']=$kw;
  $uid=(int)$kw;
  $xxx2.=" and (`key2` like '%$kw%' or key8 like '%$kw%' or id='$uid')";
  
  $data_table=$G['this']->data()->open('money')->data_table;
  $xxx.=" and userid in (select id from onez_$data_table where `namespace`='{$G['user']['namespace']}' and `tablename`='{$G['user']['tablename']}'$xxx2)";
  
}


onez('admin')->header();

$record=$G['this']->data()->open('credit.log')->page("1$xxx order by id desc");
?>
<section class="content-header">
  <h1>
    <?=$G['title']?><small></small>
  </h1>
  <ol class="breadcrumb">
    <li>
      <a href="<?php echo onez()->href('/')?>">
        <i class="fa fa-dashboard">
        </i>
        管理首页
      </a>
    </li>
    <li class="active">
      <?=$G['title']?>
    </li>
  </ol>
</section>
<section class="content">
  <div class="btns" style="padding-bottom: 10px">
    <div class="pull-left">
<form id="form-search" method="post" style="padding-bottom: 10px">
<table>
	<tr>
		<td><input class="form-control" id="input-kw" name="kw" type="text" style="width: 300px" placeholder="请填写昵称/登录账号/编号" value="<?=$kw?>"></td>
		<td style="padding-left: 5px">
        <button type="submit" class="btn btn-primary">
          查询
        </button>
    </td>
	</tr>
</table>
  </form>
    </div>
    <div class="pull-right">
    </div>
    <div class="clearfix"></div>
  </div>
  <div class="box box-info">
    <div class="box-header with-border">
      <h3 class="box-title">
        <?=$G['title']?>
      </h3>
      <div class="box-tools pull-right">
      </div>
    </div>
    <div class="box-body  table-responsive no-padding">
      <table class="table table-striped">
        <thead>
          <tr>
            <th style="text-align: right"><?=onez('chat.group.plugin.credit')->name()?></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]'");
            $amt=onez('chat.group.plugin.credit')->format($rs['key2']);
            if($amt>0){
              $amt='<span style="color:green">+'.$amt.'</span>';
            }elseif($amt<0){
              $amt='<span style="color:red">'.$amt.'</span>';
            }
             ?>
          <tr>
            <td style="text-align: right"><?=$amt?></td>
            <td><?=$rs['key1']?></td>
            <td><?=date('Y-m-d H:i:s',$rs['addtime'])?></td>
            <td>
              <img src="<?=onez('chat.group.common')->avatar($rs['userid'])?>" width="16" height="16" />
              <?=$u['nickname']?>
            </td>
          </tr>
          <?php }?>
        </tbody>
      </table>
    </div>
<?if($record[1]){ ?>
    <div class="box-footer clearfix">
      <?=$record[1]?>
    </div>
<? } ?>
  </div>
</section>
<?php
onez('admin')->footer();
?>