
{% load evelinks %}
{% load i18n %}

<div id="corps" class="tab-pane fade panel panel-default">
    <div class="panel-body">
        <h4>{% translate "Corporations (Click Alliance Name to See Corps)" %}</h4>

        <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
            {% if permissions.stats.corp.view_other %}
                {% for key, value in data.items %}
                    <div class="panel panel-default">
                        <div class="panel-heading" role="tab" id="heading{% if key == 'No Alliance' %}0000{% else %}{{ value.0 }}{% endif %}">
                            <h4 class="panel-title">
                                {% if key == 'No Alliance' %}
                                    <img src="{{ 1|alliance_logo_url:32 }}" alt="{% translate 'No Alliance' %}">
                                {% else %}
                                    <img src="{{ value.0|alliance_logo_url:32 }}" alt="{{ key }}">
                                {% endif %}

                                <a role="button"
                                   class="collapsed"
                                   data-toggle="collapse"
                                   data-parent="#accordion"
                                   href="#{% if key == 'No Alliance' %}0000{% else %}{{ value.0 }}{% endif %}"
                                   aria-expanded="false"
                                   aria-controls="{% if key == 'No Alliance' %}0000{% else %}{{ value.0 }}{% endif %}"
                                >
                                    {{ key }}
                                </a>

                                {% if key != 'No Alliance' %}
                                    <a class="btn btn-primary btn-sm pull-right" href="{% url 'afat:stats_ally' value.0 year %}" role="button">
                                        <span class="glyphicon glyphicon-eye-open" style="color: rgb(255,255,255);"></span>
                                    </a>
                                {% endif %}
                            </h4>
                        </div>

                        <div id="{% if key == 'No Alliance' %}0000{% else %}{{ value.0 }}{% endif %}" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading{% if key == 'No Alliance' %}0000{% else %}{{ value.0 }}{% endif %}">
                            <div class="panel-body">
                                <table class="table table-striped">
                                    <tbody>
                                        {% for corp in value %}
                                            {% if forloop.first %}
                                            {% else %}
                                                <tr>
                                                    <td><img src="{{ corp.0|corporation_logo_url:32 }}" alt="{{ corp.1 }}"></td>
                                                    <td>{{ corp.1 }}</td>
                                                    <td class="text-right">
                                                        <a class="btn btn-primary btn-sm" href="{% url 'afat:stats_corp' corp.0 year %}">
                                                            <span class="glyphicon glyphicon-eye-open"></span>
                                                        </a>
                                                    </td>
                                                </tr>
                                            {% endif %}
                                        {% endfor %}
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                {% endfor %}
            {% elif permissions.stats.corp.view_own %}
                <table class="table table-striped">
                    <tbody>
                        <tr>
                            <td><img src="{{ data.0.0|corporation_logo_url:32 }}" alt="{{ data.0.1 }}"></td>
                            <td>{{ data.0.1 }}</td>
                            <td class="text-right">
                                <a class="btn btn-primary btn-sm" href="{% url 'afat:stats_corp' data.0.0 year %}">
                                    <span class="glyphicon glyphicon-eye-open"></span>
                                </a>
                            </td>
                        </tr>
                    </tbody>
                </table>
            {% endif %}
        </div>
    </div>
</div>
