{% extends 'admin/layout.html.twig' %}

{% set menu = 'admin_coin_records' %}

{% block main %}

    <form id="coin-orders-search-form" class="form-inline well well-sm" action="" method="get" novalidate>

        <div class="form-group"> 
          <select class="form-control" name="type" onchange="submit();"> 
               {% set options = {'inflow':'充值记录'|trans,'outflow':'消费记录'|trans,'':'全部记录'|trans} %}
            {{ select_options(options, app.request.get('type')) }} 
          </select> 
        </div> 
        <div class="form-group"> 
          <select class="form-control" name="createdTime" onchange="submit();"> 
               {% set options = {'oneWeek':'最近一周'|trans,'oneMonth':'最近一个月'|trans,'threeMonths':'最近三个月'|trans,'all':'全部记录'|trans,} %}
            {{ select_options(options, app.request.get('createdTime')) }} 
          </select> 
        </div> 

        <div class="form-group">
            <select class="form-control" name="keywordType">
          {{ select_options(dict('coinRecordType'), app.request.query.get('keywordType'), '--选择类型--'|trans) }}
        </select>
        </div>

        <div class="form-group">
            <input type="text" id="keyword" name="keyword" class="form-control" value="{{ app.request.query.get('keyword') }}" placeholder="{{'关键词'|trans}}">
        </div>

      <button class="btn btn-primary">{{'搜索'|trans}}</button>
      <a class="btn btn-primary" href="{{ path('admin_bill_export_csv',{
      cashType:cashType,
      createdTime:app.request.get('createdTime'),
      type:app.request.get('type'),      
      keywordType:app.request.query.get('keywordType'),
      keyword:app.request.query.get('keyword'),
      })}}">{{'导出结果'|trans}}</a>
    </form>
  
    <p class="text-muted">
      <span class="mrl">{{'网校余额：'|trans}}<strong class="amount-num">{{amounts|default(0)}}</strong> {{ setting('coin.coin_name') }}</span>
      <span class="mrl">{{'充值：'|trans}}<strong class="inflow-num">{{inflow|default(0)}}</strong> {{ setting('coin.coin_name') }}</span>
      <span class="mrl">{{'消费：'|trans}}<strong class="outflow-num">{{outflow|default(0)}}</strong> {{ setting('coin.coin_name') }}</span>
    </p>
    <div class="table-responsive">
      <table class="table table-striped" style="word-wrap: break-word;
word-break: break-all;">
        <tr>
          <th width="15%">{{'流水号'|trans}}</th>
          <th width="30%">{{'名称'|trans}}</th>
          <th>{{'用户'|trans}}</th>
          <th >{{'成交时间'|trans}}</th>
          <th class="text-right" style="padding-right: 50px;">{{'收支'|trans}}</th>
        </tr>
       {% for cash in cashes %}
       <tr>
            <td>{{cash.sn}}</td>
            <td>{{cash.name}}<br>
                <span class="text-muted text-sm">{{'订单号：'|trans}}{{cash.orderSn}}</span></td>
            <td>   <a target="_blank" href="{{ path('user_show', {id:cash.userId}) }}">
            {{users[cash.userId].nickname}}</a></td>
            <td>{{cash.createdTime|date('Y-m-d H:i:s')}}</td>     
            {% if cash.type =="inflow" %}
            <td class="text-right" style="color:#1bb974;padding-right: 50px;">
               {{cash.amount}} 
            </td>
            {% endif %}
            {% if cash.type =="outflow" %}
            <td  class="text-right" style="color:#ff7b0e;padding-right: 50px;">
               -&nbsp;{{cash.amount}}               
            </td>
            {% endif %}
       </tr>
       {% endfor %}
      </table>
    </div>
 {{ admin_macro.paginator(paginator) }}

{% endblock %}