{% extends 'layout/page.html' %}

{% block head_title %}
  {% trans %}User listing{% endtrans %} - {{ config.TRACKER_NAME }}
{% endblock %}

{% block page_header %}
  {% trans %}User listing{% endtrans %}
{% endblock %}

{% block content %}

  {% include 'layout/permission.html' %}

  {% if context.is_view_ok() %}
    <table class='table'>
      <tr class='info'>
        <td>{% trans %}Username{% endtrans %}</td>
        <td>{% trans %}Real name{% endtrans %}</td>
        <td>{% trans %}Organisation{% endtrans %}</td>
        <td>{% trans %}Email address{% endtrans %}</td>
        <td>{% trans %}Phone number{% endtrans %}</td>
        {% if context.is_retire_ok() %}
          <td>{% trans %}Retire{% endtrans %}</td>
        {% endif %}
      </tr>
      {% for user in context.list() %}
        <tr>
          <td>
            <a href='user{{ user.id }}'>{{ user.username.plain()|u }}</a>
          </td>
          <td>{{ user.realname.plain()|u }}</td>
          <td>{{ user.organisation.plain()|u }}</td>
          <td>{{ user.address.email()|u }}</td>
          <td>{{ user.phone.plain()|u }}</td>
          {% if context.is_retire_ok() %}
            <td>
              <form method="POST" action='user{{ user.id }}' class='form-inline'>
                <input type="hidden" name="@template" value="index">
                <input name="@csrf" type="hidden"
                       value="{{ utils.anti_csrf_nonce() }}">
                <input type="hidden" name="@action" value="retire">
                <input type="submit" value="{% trans %}retire{% endtrans %}" class='btn btn-sm btn-danger'>
              </form>
            </td>
          {% endif %}
        </tr>
      {% endfor %}
    </table>
  {% endif %}

{% endblock %}
