{% extends request.ajax ? "layout_blank.phtml" : "layout_default.phtml" %}
{% import "macro_functions.phtml" as mf %}
{% block meta_title %}Staff members login history{% endblock %}
{% set active_menu = 'activity' %}

{% block content %}
<div class="widget first">
    <div class="head"><h5 class="iFrames">{% trans 'Staff members logins history' %}</h5></div>

{{ mf.table_search }}
<table class="tableStatic wide">
    <thead>
        <tr>
            <td colspan="2">{% trans 'Admin' %}</td>
            <td>{% trans 'IP' %}</td>
            <td>{% trans 'Country' %}</td>
            <td>{% trans 'Date' %}</td>
            <td style="width: 5%">&nbsp;</td>
        </tr>
    </thead>

    <tbody>
    {% set history = admin.staff_login_history_get_list({"per_page":30, "page":request.page}|merge(request)) %}
    {% for i, event in history.list %}
    <tr>
        <td style="width:5%"><a href="{{ 'staff/manage'|alink }}/{{ event.staff.id }}"><img src="{{ event.staff.email|gravatar }}?size=20" alt="{{ event.staff.email }}" /></a></td>
        <td>{{ event.staff.name }}</td>
        <td>{{ event.ip }}</td>
        <td>{{ event.ip|ipcountryname|default('Unknown') }}</td>
        <td>{{ event.created_at|date('Y-m-d H:i') }}</td>
        <td class="actions">
            <a class="bb-button btn14 bb-rm-tr api-link" data-api-confirm="Are you sure?" data-api-redirect="staff/logins" href="admin/staff/login_history_delete?id={{event.id}}"><img src="images/icons/dark/trash.png" alt=""></a>
        </td>
    </tr>
    </tbody>

    {% else %}
    <tbody>
        <tr>
            <td colspan="7">
                {% trans 'The list is empty' %}
            </td>
        </tr>
    </tbody>
    {% endfor %}

    {% if history.pages > 1 %}
    <tfoot>
        <tr>
            <td colspan="7">
                {% include "partial_pagination.phtml" with {'list': history, 'url':'staff/logins'} %}
            </td>
        </tr>
    </tfoot>
    {% endif %}
</table>

</div>

{% endblock %}
