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

{% block content %}
<div class="widget first">
    <div class="head"><h5 class="iFrames">{% trans 'System activity' %}</h5></div>

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

    <tbody>
    {% set events = admin.activity_log_get_list({"per_page":10, "page":request.page}|merge(request)) %}
    {% for i, event in events.list %}
    <tr>
        <td>
            {% if event.client %}
            <a href="{{ 'client/manage'|alink }}/{{ event.client.id }}" title="{{ event.client.name }}"><img src="{{ event.client.email|gravatar }}?size=20" alt="{{ event.client.name }}" /></a>
            {% elseif event.staff %}
            <a href="{{ 'staff/manage'|alink }}/{{ event.staff.id }}" title="{{ event.staff.name }}"><img src="{{ event.staff.email|gravatar }}?size=20" alt="{{ event.staff.name }}" /></a>
            {% else %}
            Guest
            {% endif %}
        </td>
        <td><div style="overflow: auto; width: 250px;">{{ event.message }}</div></td>
        <td>{{ event.ip }}</td>
        <td>{{ event.ip|ipcountryname }}</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="{% trans 'Are you sure?' %}" data-api-redirect="activity" href="admin/activity/log_delete?id={{event.id}}"><img src="images/icons/dark/trash.png" alt=""></a>
        </td>
    </tr>
    </tbody>

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

    {% if events.pages > 1 %}
    <tfoot>
        <tr>
            <td colspan="6">
                {% include "partial_pagination.phtml" with {'list': events, 'url':'activity'} %}
            </td>
        </tr>
    </tfoot>
    {% endif %}
</table>

</div>
{% endblock %}
