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

{% block content %}
<div class="widget simpleTabs">
    <ul class="tabs">
        <li><a href="#tab-index">{% trans 'Notifications' %}</a></li>
        <li><a href="#tab-new">{% trans 'New note' %}</a></li>
    </ul>

    <div class="tabs_container">
        
        <div class="fix"></div>
        <div class="tab_content nopadding" id="tab-index">

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

                <tbody>
                {% set events = admin.notification_get_list({"per_page":10, "page":request.page}|merge(request)) %}
                {% for i, event in events.list %}
                <tr>
                    <td>{{ admin.system_string_render({"_tpl": event.meta_value, "_try":true })|raw }}</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'|alink }}" href="{{ 'api/admin/notification/delete'|link({'id' : event.id}) }}"><img src="images/icons/dark/trash.png" alt=""></a>
                    </td>
                </tr>
                {% else %}
                    <tr>
                        <td colspan="6">
                            {% trans 'The list is empty' %}
                        </td>
                    </tr>
                {% endfor %}
                </tbody>
            </table>
            
            {% include "partial_pagination.phtml" with {'list': events, 'url':'notification'} %}
            
            <div class="body">
                <a href="{{ 'api/admin/notification/delete_all'|link }}"  title="" class="btnIconLeft mr10 api-link" data-api-confirm="{% trans 'Are you sure?' %}" data-api-reload="1"><img src="images/icons/dark/trash.png" alt="" class="icon"><span>{% trans 'Delete all messages' %}</span></a>
            </div>

        </div>
        
        <div class="tab_content nopadding" id="tab-new">
            <form method="post" action="{{ 'api/admin/notification/add'|link }}" class="mainForm api-form" data-api-reload="1">
                <fieldset>
                    <div class="rowElem noborder">
                        <div class="formBottom">
                            <textarea cols="5" rows="10" name="message" placeholder="{% trans 'Add note or todo task' %}" ></textarea>
                        </div>
                        <div class="fix"></div>
                    </div>

                     <input type="submit" value="{% trans 'Add note' %}" class="greyishBtn submitForm" />
                </fieldset>
            </form>
        </div>
    </div>
</div>

{% endblock %}
