{% extends '@ChillEvent/layout.html.twig' %}

{% import '@ChillPerson/Person/macro.html.twig' as person_macro %}

{% block event_content -%}
<div class="col-10">
    <h1>{{ 'Participation Edit'|trans }}</h1>

    <table class="table">
        <tbody>
            <tr>
                <th>{{ 'Associated event'|trans }} </th>
                <td>{{ event.name }}</td>
            </tr>
            <tr>
                <th>{{ 'Date'|trans }} </th>
                <td>{{ event.date|format_date('long') }}</td>
            </tr>
        </tbody>
    </table>

    <h2 class="mt-5">{{ 'Participations'|trans }}</h2>

    {{ form_start(form) }}

     <table class="table">
            <thead>
                <tr>
                    <th>{{ 'Person'|trans }}</th>
                    <th>{{ 'Role'|trans }}</th>
                    <th>{{ 'Status'|trans }}</th>
                    <th>{{ 'Last update'|trans }}</th>
                    <th>&nbsp;</th>
                </tr>
            </thead>
            <tbody>
                {% for participation in form.participations %}
                    <tr>
                        <td>{{ person_macro.render(participation.vars.value.person) }}</td>
                        <td>{{ form_widget(participation.role) }}</td>
                        <td>{{ form_widget(participation.status) }}</td>
                        <td>{{ participation.vars.value.lastUpdate|ago }} {# sf4 check: filter 'time_diff' is abandoned,
                             alternative: knplabs/knp-time-bundle provide filter 'ago' #}
                            <i class="fa fa-info-circle" title="{{ participation.vars.value.lastUpdate|format_date("long")|escape('html_attr') }}"></i>
                        </td>
                    </tr>
                {% endfor %}
            </tbody>
     </table>

    <ul class="record_actions">
        <li>
            <a href="{{ path('chill_event__event_show', { 'id' : event.id } ) }}" class="btn btn-cancel">
                {{ 'Back to the event'|trans }}
            </a>
        </li>
        <li>
            {{ form_widget(form.submit, { 'attr' : { 'class' : 'btn btn-edit' } } ) }}
        </li>
    </ul>

    {{ form_end(form) }}
</div>
{% endblock %}
