{{ moduleHeader('user', 'Members'|trans, true, true) }}
<h3>
    <span class="fas fa-users"></span>
    {% trans %}Registered users{% endtrans %}
</h3>
<form action="{{ path('zikulaprofilemodule_members_listmembers') }}" method="post" enctype="application/x-www-form-urlencoded" class="form-inline">
    <div class="form-row">
        <div class="form-group col-md-8">
            <label for="searchby" class="col-sm-6 col-form-label">{% trans %}Search by user name{% endtrans %}</label>
            <div class="col-sm-6">
                <input id="searchby" type="text" name="searchby" value="" maxlength="50" class="form-control" /></span>
            </div>
        </div>
        <div class="col-md-4">
            <input class="btn btn-success" type="submit" value="{% trans %}Submit{% endtrans %}" />
            <a href="{{ path('zikulaprofilemodule_members_listmembers') }}" class="btn btn-secondary">{% trans %}Clear{% endtrans %}</a>
        </div>
    </div>
</form>
<div id="profile-alphafilter" class="text-center my-2">
    {{ include(alpha.template) }}
</div>

<table class="table table-bordered table-striped table-sm">
    <colgroup>
        <col id="cUserName" />
        {% if messageModule|default %}
            <col id="cMessages" />
        {% endif %}
        {% if 'url' in activeProperties %}
            <col id="cSite" />
        {% endif %}
        <col id="cActions" />
    </colgroup>
    <thead>
        <tr>
            <th id="hUserName" scope="col">{% trans %}Name{% endtrans %}</th>
            {% if messageModule|default %}
                <th id="hMessages" scope="col">{% trans %}Messages{% endtrans %}</th>
            {% endif %}
            {% if 'url' in activeProperties %}
                <th id="hSite" scope="col">{% trans %}Site{% endtrans %}</th>
            {% endif %}
            <th id="hActions" scope="col">{% trans %}Actions{% endtrans %}</th>
        </tr>
    </thead>

    <tbody>
        {% for user in paginator.results|filter(u => u.uid != constant('Zikula\\UsersModule\\Constant::USER_ID_ANONYMOUS')) %}
        <tr>
            <td headers="hUserName"><strong>{{ user.uname|profileLinkByUserName() }}</strong>&nbsp;({{ user.uname }})&nbsp;
                {% set online = user|onlineSince(getModVar('ZikulaProfileModule', 'activeminutes', 10)) %}
                {% if online is same as(true) %}
                    <a href="{{ path('zikulaprofilemodule_members_online') }}" title="{% trans %}View users online{% endtrans %}"><span class="badge badge-success">{% trans %}online{% endtrans %}</span></a>
                {% elseif online is same as(false) %}
                    <span class="badge badge-danger">{% trans %}offline{% endtrans %}</span>
                {% endif %}
            </td>
            {% if messageModule|default %}
                <td headers="hMessages"><a href="{{ user.uid|messageSendLink(true) }}"><i class="fas fa-envelope fa-lg"></i></a></td>
            {% endif %}
            {% if 'url' in activeProperties %}
                <td headers="hSite">
                    {% set url = user.attributes[prefix ~ ':url']|default %}
                    {% if url and url != 'http://' %}
                    <a href="{{ url|e('html_attr') }}"><i class="fas fa-globe fa-lg" title="{{ url|e('html_attr') }}"></i></a>
                    {% endif %}
                </td>
            {% endif %}
            {% set rowActions = knp_menu_get('zikulaProfileAdminMenu', [], {user: user}) %}
            <td headers="hActions" class="actions">
                {{ knp_menu_render(rowActions, {template: '@ZikulaMenuModule/Override/actions.html.twig'}) }}
            </td>
        </tr>
        {% else %}
            <tr class="table-info"><td colspan="4" class="text-center">{% trans %}No users found.{% endtrans %}</td></tr>
        {% endfor %}
    </tbody>
</table>
{{ include(paginator.template) }}

<h3>{% trans %}Statistics{% endtrans %}</h3>
<ul id="profile_status">
    <li><strong>{% trans %}Registered:{% endtrans %}</strong> {{ amountOfRegisteredMembers }}</li>
    <li><strong>{% trans %}Online:{% endtrans %}</strong> <a href="{{ path('zikulaprofilemodule_members_online') }}" title="{% trans %}View users online{% endtrans %}">{{ amountOfOnlineMembers }}</a></li>
    <li><strong>{% trans %}Newest user:{% endtrans %}</strong> <a href="{{ path('zikulaprofilemodule_profile_display', { uid: newestMember.uid }) }}" title="{% trans with {'%uname%': newestMember.uname} %}View profile of %uname%{% endtrans %}">{{ newestMember.uname }}</a></li>
</ul>
