{% 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">{{ 'Notifications'|trans }}</a></li>
        <li><a href="#tab-new">{{ 'New note'|trans }}</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>{{ 'Message'|trans }}</td>
                        <td>{{ 'Date'|trans }}</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="{{ 'Are you sure?'|trans }}" 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">
                            {{ 'The list is empty'|trans }}
                        </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="{{ 'Are you sure?'|trans }}" data-api-reload="1"><img src="images/icons/dark/trash.png" alt="" class="icon"><span>{{ 'Delete all messages'|trans }}</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="{{ 'Add note or todo task'|trans }}" ></textarea>
                        </div>
                        <div class="fix"></div>
                    </div>

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