{% extends 'coin/layout.html.twig' %}
{% block title %}
  我的{{setting('coin.coin_name')}} - {{ parent() }}
{% endblock %}

{% set side_nav = 'my-coin' %}

{% block main %}
  <div class="es-section h400">
    {% include 'coin/bill-bar.html.twig' %}
    <span class="label label-primary label-md">{{'账户余额'|trans}}</span>
    {% if setting('coin.coin_content') %}
      <a href="{{ path('coin_show') }}" target="_blank" class="pull-right link-primary">{{'%coin_name%说明'|trans({'%coin_name%': setting('coin.coin_name')|default('虚拟币'|trans)})}}</a>
    {% endif %}
    <br>
    <div class="coin-block clearfix">
      <div class="coin-text">
        {% if setting('coin.coin_picture') %}
          <img class="coin-picture" src="{{asset(setting('coin.coin_picture')) }}" alt="{{'虚拟币图片'|trans}}" width="30px" >
        {% endif %}
        <strong>{{account.cash|default(0)}}</strong>
      </div>

      {% if setting('coin.coin_enabled') %}
        <div class="coin-btn">
          {% if is_plugin_installed('ChargeCoin') and setting('coin.charge_coin_enabled') %}
            <a href="{{path('my_coin_buy')}}" target="_blank" class="mll btn btn-primary"> &nbsp;&nbsp;{{'充&nbsp;值'|trans|raw}}&nbsp;&nbsp; </a>
          {% endif %}
          {% if is_plugin_installed('MoneyCard') %}
            <a href="{{path('money_card_use')}}" target="_blank" class="mll btn btn-default">{{'使用学习卡'|trans}}</a>
          {% endif %}
        </div>
      {% endif %}
    </div>
    <hr>
    <ul class="nav nav-pills" role="tablist">
      <li role="presentation" {% if app.request.query.get('type') != "inflow" and app.request.query.get('type') != "outflow" %}class="active"{% endif %}><a href="{{path('my_coin',{type:''})}}">{{'全部记录'|trans}}</a></li>
      <li role="presentation" {% if app.request.query.get('type') == "inflow" %}class="active"{% endif %}><a href="{{path('my_coin',{type:'inflow'})}}">{{'充值记录'|trans}}</a></li>
      <li role="presentation" {% if app.request.query.get('type') == "outflow" %}class="active"{% endif %}><a href="{{path('my_coin',{type:'outflow'})}}">{{'消费记录'|trans}}</a></li>
    </ul>
    <br>
    <form id="user-search-form" class="form-inline well well-sm clearfix" action="" method="get" novalidate>
      <div class="form-group">
        <input type="hidden" name="type" value="{{ app.request.query.get('type')|default('') }}">
        <select class="form-control" name="lastHowManyMonths" onchange="submit();">
          {% set options = {'':'全部记录'|trans,'oneWeek':'最近一周'|trans,'twoWeeks':'最近两周'|trans,'oneMonth':'最近一个月'|trans,'twoMonths':'最近两个月'|trans,'threeMonths':'最近三个月'|trans} %}
          {{ select_options(options, app.request.get('lastHowManyMonths')) }}
        </select>
      </div>

      <div class="control-label pull-right" style="padding-top: 8px;">
        {% if app.request.query.get('type') != "outflow"  %}
          {{'收入：'|trans}}<span style="color:#1bb974;">{{ amountInflow }}</span>&nbsp;{{setting('coin.coin_name')}}
        {% endif %}
        {% if app.request.query.get('type') != "inflow"  %}
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          {{'支出：'|trans}}<span style="color:#ff7b0e;">{{ amountOutflow }}</span>&nbsp;{{setting('coin.coin_name')}}
        {% endif %}
      </div>
    </form>
    <br>
    <div class="table-responsive">
      <table class="table table-striped">
        {% if cashes %}
        <tr>
          <th><span class="text-sm">{{'流水号'|trans}}</span></th>
          <th><span class="text-sm">{{'名称'|trans}}</span></th>
          <th><span class="text-sm">{{'成交时间'|trans}}</span></th>
          <th class="text-right" style="padding-right: 60px;"><span class="text-sm">{{'收支'|trans}}</span></th>
          <th><span class="text-sm">{{'支付方式'|trans}}</span></th>
        </tr>
        {% for cash in cashes %}
          <tr>
            <td><span class="text-sm">{{cash.sn}}</span></td>
            <td><span class="text-sm">{{cash.name}}</span><br>
                <span class="color-gray text-sm">{{'订单号：'|trans}}{{cash.orderSn}}</span></td>
            <td><span class="text-sm">{{cash.createdTime|date('Y-m-d H:i:s')}}</span></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 %}

            <td>
              <span class="text-sm">
                {% if cash.cashType == "Coin" and cash.category == "inflow" %}
                {{'学习卡充值'|trans}}
                {% elseif cash.cashType == "Coin" and cash.category == "change" %}
                  {{ dict_text('payment', cash.payment) }}
                {% elseif cash.category == "moneyCardRecharge" %}
                {{'学习卡'|trans}}
                {% else %}
                {{'余额支付'|trans}}
                {% endif %}
              </span>
            </td>
          </tr>
        {% endfor %}
        {% else %}
          <div class="empty">{{'暂无记录'|trans}}</div>
        {% endif %}
      </table>
    </div>
    <nav class="text-center">
      {{ web_macro.paginator(paginator) }}
    </nav>
  </div>
{% endblock %}