{% extends 'card/layout.html.twig' %}
{% do script(['app/js/card/index/index.js']) %}
{% set main_nav = 'cards' %}

{% block main_body %}
  {% if app.request.cookies.get('modalOpened') == 1 %}
    <a href="#modal" class="receive-modal hidden" data-toggle="modal" data-url="{{ path('card_info',{'cardType':app.request.query.get('cardType'),'cardId':app.request.query.get('cardId')}) }}" ><span class=""></span></a>
  {% endif %}
  <div class="clearfix mbl">
    <ul class="nav nav-pills inline-block">
      <li role="presentation" {% if app.request.query.get('cardType')=='' or app.request.query.get('cardType')=='coupon' %} class="active"{% endif %}><a href="{{ path('my_cards',{ cardType:''}) }}">{{'优惠码'|trans}}</a></li>
    {% if is_plugin_installed("MoneyCard") %}
      <li role="presentation" {% if app.request.query.get('cardType')=='moneyCard' %} class="active"{% endif %}><a href="{{ path('my_cards',{ cardType:'moneyCard'}) }}">{{'学习卡'|trans}}</a></li>
    {% endif %}
    </ul>

    <div class="pull-right btn-group">
    {% if is_plugin_installed("MoneyCard") %}
        <a role="filter-change" class="btn btn-default {% if app.request.query.get('filter') == '' or app.request.query.get('filter') == 'all' %}btn-primary{% endif %}" data-url='{{ path('my_cards',{cardType:app.request.query.get('cardType'),filter:''}) }}'>{{'全部'|trans}}</a>
        <a role="filter-change" class="btn btn-default {% if app.request.query.get('filter') == 'useable' %}btn-primary{% endif %}" data-url='{{ path('my_cards',{cardType:app.request.query.get('cardType'),filter:'useable'}) }}'>{{'未使用'|trans}}</a>
        <a role="filter-change" class="btn btn-default {% if app.request.query
        .get('filter') == 'used' %}btn-primary{% endif %}" data-url='{{ path('my_cards',{cardType:app.request.query.get('cardType'),filter:'used'}) }}'>{{'已使用'|trans}}</a>
        <a role="filter-change" class="btn btn-default {% if app.request.query.get('filter') == 'outdate' %}btn-primary{% endif %}" data-url='{{ path('my_cards',{cardType:app.request.query.get('cardType'),filter:'outdate'}) }}'>{{'已过期'|trans}}</a>
      {% endif %}

      {% if is_plugin_installed("MoneyCard") and app.request.query.get('cardType') == "moneyCard" %}
        <a role="filter-change" class="btn btn-default {% if app.request.query.get('filter') == 'invalid' %}btn-primary{% endif %}" data-url='{{ path('my_cards',{cardType:app.request.query.get('cardType'),filter:'invalid'}) }}'>{{'已作废'|trans}}</a>
      {% endif %}
    </div>
  </div>
  <div class="card-pack-list">
    <div class="row">
      {% if setting('coin.coin_enabled') != 0 or app.request.query.get('cardType') != 'moneyCard' %}
        {% if cards is not null %}
          {% for card in cards %}
            <div class="col-lg-4 col-md-6 col-sm-6">
              {% if cardDetails[card.cardId] is defined %}{# this if condition is to be delete #}
                {% if card.cardType == 'coupon' %}
                  {% include 'card/coupon-'~card.status~'.html.twig' with {cardDetail:cardDetails[card.cardId]} %}
                {% elseif card.cardType == 'moneyCard' and is_plugin_installed('moneyCard') %}
                  {% include 'card/moneycard-'~card.status~'.html.twig' with {cardDetail:cardDetails[card.cardId]} %}
                {% endif %}
              {% endif %}
            </div>
          {% endfor %}
        {% else %}
        <div class="empty">{{'没有搜索到符合条件的'|trans}}{% if app.request.query.get('cardType')=='' or app.request.query.get('cardType')=='coupon' %}{{'优惠码'|trans}}{% else %}{{'学习卡'|trans}}{% endif %}</div>
        {% endif %}
      {% else %}
      <div class="empty">{{'网站没有开启%coin_name%功能,学习卡功能暂时没法使用'|trans({'%coin_name%': coin.coin_name|default('虚拟币'|trans)})}}</div>
      {% endif %}
    </div>
  </div>
{% endblock %}