{% extends 'base.html' %}
{% load i18n %}

{% block breadcrumb %}
    <ol class="breadcrumb">
        <li><span class="glyphicon glyphicon-home"></span></li>
        <li class="active">{% trans 'Administrators' %}</li>
    </ol>
{% endblock %}

{% block page-header %}
    {% trans 'Admin accounts list' %}
{% endblock %}

{% block main %}
    <div class="table-responsive">
        <table class="table table-striped table-bordered">
            <thead>
            <tr>
                <th class="col-sm-1">{% trans 'Photo' %}</th>
                <th class="col-sm-2">{% trans 'profile username' %}</th>
                <th class="col-sm-4">{% trans 'Fullname, or login if name is empty' %}</th>
                <th class="col-sm-2 hidden-xs">{% trans 'Telephone' %}</th>
                <th class="col-sm-2 hidden-xs">{% trans 'Email' %}</th>
                <th class="col-sm-1 hidden-xs">&mdash;</th>
            </tr>
            </thead>
            <tbody>
            {% for usr in users %}
                <tr {{ usr.is_active|yesno:',class="danger"'|safe }}>
                    <td>
                        <a href="{% url 'acc_app:other_profile' usr.id %}">
                            <img width="50" src="{{ usr.get_min_ava }}" alt="{{ usr.username }}"/>
                        </a>
                    </td>
                    <td><a href="{% url 'acc_app:other_profile' usr.id %}">{{ usr.username }}</a></td>
                    <td>{{ usr.get_full_name }}</td>
                    <td class="hidden-xs">
                        {% if usr.telephone %}
                            <a href="tel:{{ usr.telephone }}">{{ usr.telephone }}</a>
                        {% else %}
                            {% trans 'Not assigned' %}
                        {% endif %}
                    </td>
                    <td class="hidden-xs">
                        {% if usr.email %}
                            <a href="mailto:{{ usr.email }}">{{ usr.email }}</a>
                        {% else %}
                            {% trans 'Not assigned' %}
                        {% endif %}
                    </td>
                    {% if usr.id == request.user.id or perms.acc_app.delete_userprofile %}
                        <td class="btn-group hidden-xs">
                            <a href="{% url 'acc_app:delete_profile' usr.id %}" class="btn btn-sm btn-danger">
                                <span class="glyphicon glyphicon-remove"></span>
                            </a>
                        </td>
                    {% else %}
                        <td class="btn-group hidden-xs">
                            <a href="#" class="btn btn-sm btn-danger disabled" title="{% trans 'You have not permissions to delete' %}">
                                <span class="glyphicon glyphicon-remove"></span>
                            </a>
                        </td>
                    {% endif %}

                </tr>
            {% empty %}
                <tr>
                    <td colspan="6"><b>{% trans 'Users not found' %}</b></td>
                </tr>
            {% endfor %}
            </tbody>
            {% if request.user.is_superuser %}
                <tfoot>
                <tr>
                    <th colspan="6">
                        <a href="{% url 'acc_app:create_profile' %}" class="btn btn-default" title="{% trans 'Add account' %}">
                            <span class="glyphicon glyphicon-plus-sign"></span>
                        </a>
                    </th>
                </tr>
                </tfoot>
            {% endif %}
        </table>
    </div>
{% endblock %}
