{% extends request.ajax ? "layout_blank.phtml" : "layout_default.phtml" %}

{% import "macro_functions.phtml" as mf %}

{% block meta_title %}{{ 'Forum members'|trans }}{% endblock %}

{% block breadcrumb %}<li class="active">{{ 'Forum members'|trans }}</li>{% endblock %}

{% block content %}
<div class="row">
    <article class="span12 data-block" role="main">
        <div class="data-container">
            <header>
                <h1>{{ 'Forum members'|trans }}</h1>
                <p>{{ 'List of all forum members. You can filter the list by clicking on letter above to find usernames which start with this letter.'|trans }}</p>
            </header>
            <section>
                <div class="pagination">
                    <ul>
                        <li {% if not request.first_char %}class="active"{% endif %}>
                        <a href="{{ 'forum/members-list'|link }}">{{ 'All'|trans }}</a>
                        </li>
                        {% for i in range('a', 'z') %}
                        <li {% if request.first_char == i %}class="active"{% endif %}>
                        <a href="{{ 'forum/members-list'|link({ 'first_char': i }) }}#memberlist">{{ i|upper }}</a>
                        </li>
                        {% endfor %}
                    </ul>
                </div>

                <table id="memberlist" class="table table-striped table-bordered table-condensed">
                    <thead>
                    <tr>
                        <th>{{ 'Username'|trans }}</th>
                        <th>{{ 'Posts'|trans }}</th>
                        <th>{{ 'Joined'|trans }}</th>
                    </tr>
                    </thead>

                    <tbody>
                    {% set members = guest.forum_members_list({ "per_page": 20 }|merge(request)) %}
                    {% for member in members.list %}
                    <tr>
                        <td>{{ member.name }}</td>
                        <td>{{ member.posts }}</td>
                        <td>{{ member.created_at|bb_date }}</td>
                    </tr>
                    {% else %}
                    <tr>
                        <td colspan="3"><div class="text-center">{{ 'The list is empty'|trans }}</div></td>
                    </tr>
                    {% endfor %}
                    </tbody>
                </table>
            </section>
        </div>
    </article>
</div>
{% endblock %}
