{% extends 'fleet/base.html' %}

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

{% block fleet_block %}
    {% if error %}
        <div class="alert alert-danger" role="alert">{{ error }}</div>
    {% endif %}

    <div class="panel panel-default">
        <div class="panel-heading">
            <div class="panel-title">
                {% translate "Available Fleets" %}
            </div>
        </div>

        <div class="panel-body">
            <table class="table table-striped table-hover">
                <thead>
                    <th></th>
                    <th>{% translate "Name" %}</th>
                    <th>{% translate "Created At" %}</th>
                    <th>{% translate "Join" %}</th>

                    {% if perms.fleet.manage %}
                        <th>{% translate "Details" %}</th>
                    {% endif %}

                    {% if perms.fleet.manage %}
                        <th>{% translate "Edit" %}</th>
                    {% endif %}
                </thead>

                <tbody>
                    {% for fleet in fleets %}
                        <tr>
                            <td>
                                <img class="img-circle eve-character-portrait" style="display: block; margin: auto;" src="{{ fleet.fleet_commander_id|character_portrait_url:32 }}">
                            </td>

                            <td>
                                {{fleet.name}}
                            </td>

                            <td>
                                {{fleet.created_at|date:"Y-m-d H:i"}}
                            </td>

                            <td>
                                <a href="{% url 'fleet:join_fleet' fleet.fleet_id %}" class="btn btn-sm btn-default">{% translate "Join Fleet" %}</a>
                            </td>

                            {% if perms.fleet.manage %}
                                <td>
                                    <a href="{% url 'fleet:fleet_details' fleet.fleet_id %}"  class="btn btn-sm btn-default">{% translate "View fleet details" %}</a>
                                </td>
                            {% endif %}

                            {% if perms.fleet.manage %}
                                <td>
                                    <a href="{% url 'fleet:edit_fleet' fleet.fleet_id %}"  class="btn btn-sm btn-default">{% translate "Edit Fleet advert" %}</a>
                                </td>
                            {% endif %}
                        </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>
    </div>
{% endblock %}
