<h2>{{ 'Event search'|trans }}</h2>

<p>
    {{ 'total events match the search'|trans({'total' : total}) }}&nbsp;:
    <a href="{{ path('chill_main_advanced_search', { "name": search_name, "q": pattern } ) }}" class="btn btn-sm">
        <i class="fa fa-search" aria-hidden="true"></i> {{ pattern }}
    </a>
</p>

<style>
    table.events td:last-child {
        width: 15em;
    }
</style>
{% if events|length > 0 %}

    <p>{{ 'Results %start%-%end% of %total%'|trans({ '%start%' : start, '%end%': start + events|length, '%total%' : total } ) }}</p>
    <table class="table table-bordered border-dark align-middle events">
        <thead>
        <tr>
            <th class="chill-red">{{ 'Name'|trans }}</th>
            <th class="chill-green">{{ 'Date'|trans }}</th>
            <th class="chill-orange">{{ 'Event type'|trans }}</th>
            <th>&nbsp;</th>
        </tr>
        </thead>
        <tbody>
        {% for event in events %}
            <tr>
                <td>{{ event.name }}</td>
                <td>{{ event.date|format_date('long') }}</td>
                <td>{{ event.type.name|localize_translatable_string }}</td>
                <td>
                    <ul class="record_actions">
                        <li>
                            {# {% if is_granted('CHILL_EVENT_SEE_DETAILS', event) %} #}
                            <a href="{{ path('chill_event__event_show', { 'id' : event.id } ) }}" class="btn btn-view">
                                {{ 'See'|trans }}
                            </a>
                            {# {% endif %} #}
                            {% if is_granted('CHILL_EVENT_UPDATE', event) %}
                                <a href="{{ path('chill_event__event_edit', { 'event_id' : event.id } ) }}" class="btn btn-update">
                                    {{ 'Edit'|trans }}
                                </a>
                            {% endif %}
                        </li>
                    </ul>
                </td>
            </tr>
        {% endfor %}
        </tbody>
    </table>

{% endif %}

<ul class="record_actions">
    <li>
        <a href="{{ path('chill_event__event_new_pickcenter') }}" class="btn btn-create" >
            {{ 'New event'|trans }}
        </a>
    </li>
    {% if preview == true and events|length < total %}
        <li>
            <a href="{{ path('chill_main_search', { "name": search_name, "q" : pattern }) }}" class="btn btn-misc">
                {{ 'See all results'|trans }}
            </a>
        </li>
    {% endif %}

</ul>

{% if preview == false %}
    {{ chill_pagination(paginator) }}
{% endif %}

