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

<div class="table-responsive">
    <table class="table table-hover table-striped table-width-fix" id="tbl-characters">
        <thead>
            <tr>
                <th>{% translate "Character" %}</th>
                <th>{% translate "Corporation" %}</th>
                <th>{% translate "Alliance" %}</th>
                <th>{% translate "Scopes" %}</th>
                <th>{% translate "Standing" %}</th>
                <th>{% translate "Actions" %}</th>
            </tr>
        </thead>
        <tbody>
            {% for std in characters %}
                <tr>
                    <td>
                        <img src="{{ std.character|character_portrait_url:32 }}" class="img-circle">&nbsp;&nbsp;&nbsp;{{ std.character.character_name }}
                    </td>
                    <td>
                        [{{ std.character.corporation_ticker }}] {{ std.character.corporation_name }}
                    </td>
                    <td>
                        {{ std.character.alliance_name|default_if_none:"" }}
                    </td>
                    <td>
                        {% if std.hasRequiredScopes %}
                            <i class="fas fa-check fa-fw fa-lg text-success" title="Has required scopes"></i>
                        {% else %}
                            <a title="{% translate 'Add required scopes' %}" class="btn btn-danger btn-sm" href="{% url 'standingsrequests:view_requester_add_scopes' %}">
                                <i class="fas fa-plus fa-fw fa-lg"></i> {% translate "Required" %}
                            </a>
                        {% endif %}
                    </td>
                    <td>
                        {% if std.inOrganisation == True %}
                            <i class="fas fa-star fa-fw fa-lg text-primary" title="{% translate 'In Organisation' %}"></i>
                        {% elif std.requestActioned == True %}
                            <i class="fas fa-hourglass-half fa-lg fa-fw text-success" title="{% translate 'Accepted, pending update in game.' %}"></i>
                        {% elif std.pendingRequest == True %}
                            <i class="fas fa-hourglass-start fa-lg fa-fw" title="{% translate 'Standing Pending' %}"></i>
                        {% elif std.pendingRevocation == True %}
                            <i class="fas fa-reply-all fa-fw fa-lg text-danger" title="{% translate 'Standing is being revoked' %}"></i>
                        {% elif std.standing == None and std.pendingRequest == False %}
                            <i class="fas fa-exclamation-triangle fa-lg text-warning" title="{% translate 'No Standing' %}"></i>
                        {% else %}
                            {% include 'standingsrequests/partials/standing_symbol.html' with standing=std.standing %}
                        {% endif %}
                    </td>
                    <td>
                        {% if std.inOrganisation == True %}
                            <!-- Already in organisation, No actions -->
                        {% elif std.pendingRequest == True or std.requestActioned == True %}
                            <a
                                class="btn btn-warning"
                                role="button"
                                href="{% url 'standingsrequests:remove_character_standing' character_id=std.character.character_id %}"
                                title="Cancel Request">
                                Cancel
                            </a>
                        {% elif std.pendingRevocation == True %}
                            <!-- Revoked, No actions -->
                        {% elif not std.hasStanding %}
                            {% if std.hasRequiredScopes %}
                                <a
                                    class="btn btn-primary"
                                    role="button"
                                    href="{% url 'standingsrequests:request_character_standing' character_id=std.character.character_id %}"
                                    title="Request to get standing for this character"
                                    >
                                    &nbsp;Apply&nbsp;
                                </a>
                            {% else %}
                                <button class="btn btn-primary" role="button" title="Missing scopes" disabled>
                                    &nbsp;Apply&nbsp;
                                </button>
                            {% endif %}
                        {% else %}
                            <a
                                class="btn btn-danger"
                                role="button"
                                href="{% url 'standingsrequests:remove_character_standing' character_id=std.character.character_id %}"
                                title="Request to revoke standing for this character">
                                Revoke
                            </a>
                        {% endif %}
                    </td>
                </tr>
            {% endfor %}
        </tbody>
    </table>
</div>
