{% extends "standingsrequests/base.html" %}
{% load bootstrap %}
{% load static %}
{% load i18n %}

{% block page_content %}
    <div ng-app="standingsApp" ng-controller="ViewRequestsController">
        <error-messages></error-messages>

        <!-- Requests -->

        <h2 style="margin-top:0;">
            {% trans "Effective Requests" %} ({{requests_count|default:"-"}})
        </h2>
        <p>All effective standing requests for <strong>{{organization.name}}</strong></p>
        <div class="container-fluid">

            <div id="div_spinner" class="row">
                <div class="col-md-12">
                    {% include "standingsrequests/partials/_spinner.html" %}
                </div>
            </div>

            <div id="div_requests" class="row" style="visibility: hidden">
                <div class="table-responsive">
                    <table class="table table-condensed table-hover table-striped">
                        <tr>
                            <th class="col-md-1">{% trans "Date" %}</th>
                            <th class="col-md-2">{% trans "Contact Name" %}</th>
                            <th class="col-md-2">{% trans "Corporation / Alliance" %}</th>
                            <th class="col-md-2">{% trans "Main Character" %}</th>
                            <th class="col-md-1">{% trans "Scopes / State" %}</th>
                            <th class="col-md-2">{% trans "Effective / Accepted By" %}</th>
                            <th class="col-md-1">{% trans "" %}</th>
                        </tr>
                        {% verbatim %}
                        <tr ng-repeat="contact in requests">
                            <td>
                                {{ contact.request_date | date:'yyyy-MM-dd HH:mm' }}
                            </td>
                            <td>
                                <img ng-src="{{ contact.contact_icon_url }}" class="img-circle"/>&nbsp;&nbsp;
                                {{ contact.contact_name }}
                            </td>
                            <td>
                                <span ng-show="contact.corporation_ticker">
                                    [{{ contact.corporation_ticker }}] {{ contact.corporation_name }}
                                </span><br>
                                <span ng-show="contact.alliance_name" ng-bind="contact.alliance_name"></span>
                            </td>
                            <td>
                                <img ng-src="{{ contact.main_character_icon_url }}" class="img-circle"/>&nbsp;&nbsp;
                                <span ng-show="contact.main_character_ticker">
                                    [{{ contact.main_character_ticker }}] {{ contact.main_character_name }}
                                </span>
                            </td>
                            <td>
                                <bool-checkmark value="contact.has_scopes" true-title="Has required scopes" false-title="Missing required scopes"></bool-checkmark>
                                {{contact.state}}
                            </td>
                            <td>
                                <bool-checkmark value="contact.is_effective" true-title="Standing Effective" false-title="Standing not effective"></bool-checkmark>
                                <span ng-bind="contact.action_by" ng-show="contact.action_by"></span>
                            </td>
                            <td>
                                <!--
                                <button class="btn btn-danger" ng-click="rejectRequest(contact)" title="Revoke standing of this contact">
                                    Revoke
                                </button>
                                -->
                            </td>
                        </tr>

                        <tr ng-hide="requests.length > 0">
                            <td class="text-muted" colspan="10" style="text-align: center; vertical-align: middle;">
                            Empty
                            </td>
                        </tr>

                        {% endverbatim %}
                    </table>
                </div>
            </div>
        </div>
    </div>
{% endblock page_content %}

{% block extra_javascript %}
    <script type="text/javascript">
        {% include 'standingsrequests/partials/_angular_urls.html' %}
    </script>
    <script src="{% static 'standingsrequests/app.js' %}"></script>
    <script src="{% static 'standingsrequests/error.js' %}"></script>
    <script src="{% static 'standingsrequests/standings_filter.js' %}"></script>
    <script src="{% static 'standingsrequests/manage.js' %}"></script>
    <script src="{% static 'standingsrequests/requests.js' %}"></script>
{% endblock extra_javascript %}
