{% extends "office/base.html" %}

{% load i18n %}

{% block title %}{% trans "Member List" %}{% endblock %}

{% block content %}
    <div id="member-actions" class="btn-group" role="group" aria-label="{% trans 'Member list operations' %}">
        <a href="{% url "office:members.add" %}" class="btn btn-success">
            <span class="fa fa-plus"></span> {% trans "Add new member" %}
        </a>
        <a href="{% url "office:members.balance" %}" class="btn btn-success">
            <span class="fa fa-envelope"></span> {% trans "Balances/Reminders" %}
        </a>
        <a href="{% url "office:members.disclosure" %}" class="btn btn-success">
            <span class="fa fa-envelope"></span> {% trans "Send disclosure mail" %}
        </a>
        <a href="{% url "office:members.list.export" %}" class="btn btn-success">
            <span class="fa fa-download"></span> {% trans "Export member list" %}
        </a>
        <a href="{% url "office:members.list.import" %}" class="btn btn-success">
            <span class="fa fa-upload"></span> {% trans "Import members" %}
        </a>
    </div>
    <p>
        <div class="form-group">
            <form method="get" class="form form-inline">
                <select name="filter" class="form-control">
                    <option value="">{% trans "Active members" %}</option>
                    <option value="negbalance"{% if "negbalance" == request.GET.filter %}selected{% endif %}>{% trans "Members with negative balance" %}</option>
                    <option value="inactive"{% if "inactive" == request.GET.filter %}selected{% endif %}>{% trans "Only inactive members" %}</option>
                    <option value="all" {% if "all" == request.GET.filter %}selected{% endif %}>{% trans "All members" %}</option>
                </select>
                <input name="q" class="form-control" type="text" placeholder="{% trans "Search" %}"/>
                <button type="submit" class="btn btn-success">{% trans "Filter" %}</button>
            </form>
        </div>
    </p>
    <form method="post" class="form form-inline">
        {% csrf_token %}

        <table class="table table-sm">
            <thead>
                <tr>
                    <th>{% trans "Number" %}</th>
                    <th>{% trans "Name" %}</th>
                    <th>{% trans "Balance" %}
                        <button type="submit" class="btn-success btn-small">
                            <span class="fa fa-refresh"></span> {% trans "Refresh" %}
                        </button>
                    </th>
                </tr>
            </thead>
            <tbody>
                {% for member in members %}
                    <tr>
                        <td><a href="{% url "office:members.dashboard" pk=member.pk %}">
                            {{ member.number }}
                        </a></td>
                        <td><a href="{% url "office:members.dashboard" pk=member.pk %}">
                            {{ member.name }}
                        </a></td>
                        <td>
                            <span{% if member.balance < 0 %} class="text-danger"{% endif %}>
                                {{ member.balance }}
                            </span>
                        </td>
                    </tr>
                {% endfor %}
            </tbody>
        </table>
    </form>
    {% include "office/pagination.html" %}
{% endblock %}
