{% extends 'TopxiaAdminBundle::layout.html.twig' %}

{% set menu = 'admin_coin_user' %}

{% block main %}

  {% if setting('coin.coin_enabled')  %}
    <form id="coin-orders-search-form" class="form-inline well well-sm" action="" method="get" novalidate>

        <input value="{{condition.type}}" name="flowType" type="hidden"/>
        <input value="{{condition.timeType}}" name="timeType" type="hidden"/>
        <div class="form-group">
          <select class="form-control" name="searchType"> 
               {% set options = {'nickname':'用户名','email':'邮件地址'} %}
            {{ select_options(options, app.request.get('searchType')) }} 
          </select> 
        </div>

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

      <button class="btn btn-primary">搜索</button>
    </form>
    
    <div class="well">
      <div>
      时间：

          <a type="button" class="btn btn-default btn-sm {% if condition.timeType != "threeMonths" and  condition.timeType != "oneMonth" and  condition.timeType != "all" %}btn-info{% endif %}" href="{{path('admin_coin_user_records',{timeType:"oneWeek",searchType:condition.searchType,keyword:condition.keyword})}}">本周</a>

          <a type="button" class="btn btn-default btn-sm {% if condition.timeType == "oneMonth" %}btn-info{% endif %}" href="{{path('admin_coin_user_records',{timeType:"oneMonth",searchType:condition.searchType,keyword:condition.keyword})}}">本月</a>


          <a type="button" class="btn btn-default btn-sm {% if condition.timeType == "threeMonths" %}btn-info{% endif %}" href="{{path('admin_coin_user_records',{timeType:"threeMonths",searchType:condition.searchType,keyword:condition.keyword})}}">三个月</a>

          <a type="button" class="btn btn-default btn-sm {% if condition.timeType == "all" %}btn-info{% endif %}" href="{{path('admin_coin_user_records',{timeType:"all",searchType:condition.searchType,keyword:condition.keyword})}}">全部历史</a>

      <span class="mll"></sapn>
      类型：

          <a type="button" class="btn btn-default btn-sm {% if condition.flowType != "out" and  condition.flowType != "in" %}btn-info{% endif %}" href="{{path('admin_coin_user_records',{flowType:"",timeType:condition.timeType,sort:condition.sort})}}">默认</a>

          <a type="button" class="btn btn-default btn-sm {% if condition.flowType == "out" %}btn-info{% endif %}" href="{{path('admin_coin_user_records',{flowType:"out",timeType:condition.timeType,sort:condition.sort})}}">消费</a>


          <a type="button" class="btn btn-default btn-sm {% if condition.flowType == "in" %}btn-info{% endif %}" href="{{path('admin_coin_user_records',{flowType:"in",timeType:condition.timeType,sort:condition.sort})}}">充值</a>

        <span class="mll"></sapn>
        排序：

          <a type="button" class="btn btn-default btn-sm {% if condition.sort == "up"  %}btn-info{% endif %}" href="{{path('admin_coin_user_records',{flowType:condition.flowType,timeType:condition.timeType,sort:"up"})}}">升序</a>

          <a type="button" class="btn btn-default btn-sm {% if condition.sort == "down"  %}btn-info{% endif %}" href="{{path('admin_coin_user_records',{flowType:condition.flowType,timeType:condition.timeType,sort:"down"})}}">降序</a>

      </div>
    </div>

    <div class="table-responsive">
      <table class="table table-striped">
        <tr>
          <th width="30%">用户</th>
          <th>充值 
          </th>
          <th>消费
          </a></th>
          <th>账户余额</th>
          <th>操作</th>
        </tr>

        {% if userIds %}
          {% for userId in userIds %}
             <tr>
              <td> {{ web_macro.user_link(users[userId] , 'link-muted') }}</td>
              <td style="color:#1bb974;"> {{userInCash(userId,condition.timeType)|default("0.00")}}</td>
              <td style="color:#ff7b0e;"> {{userOutCash(userId,condition.timeType)|default("0.00")}}</td>
              <td style="color:blue;"> {{userAccount(userId).cash|default(0)}}</td>
              <td>
                <a  class= {% if userAccount(userId) %} "btn btn-default"  {% else %} "btn btn-default disabled"  {% endif %} data-toggle="modal" data-target="#modal" data-url="{{path('admin_coin_flow_detail',{userId:userId,timeType:condition.timeType})}}" href="javascript:;">查看</a>
              </td>
            </tr>
          {% endfor %}
        {% endif %}
       
      </table>
      {% if not userIds %} <div class="empty">暂无记录</div>{% endif %}
      {% if paginator|default(null) %}
      {{ web_macro.paginator(paginator) }}
      {% endif %}
    </div>

{% else %}
<div class="well" style="text-align:center;">


虚拟币未开启，请先在<a href="{{ path('admin_coin_model') }}"> 系统-账务设置-虚拟币-使用方式  </a>中设置开启

</div>
{% endif %}
{% endblock %}