{% extends "@ChillPerson/AccompanyingCourse/layout.html.twig" %}

{% set activeRouteKey = 'chill_calendar_calendar_list' %}

{% block title %}{{ 'Calendar list' |trans }}{% endblock title %}

{% set user_id = null %}
{% set accompanying_course_id = accompanyingCourse.id %}

{% block js %}
    {{ parent() }}
    {{ encore_entry_script_tags('mod_answer') }}
    {{ encore_entry_script_tags('mod_document_action_buttons_group') }}
{% endblock %}

{% block css %}
    {{ parent() }}
    {{ encore_entry_link_tags('mod_answer') }}
    {{ encore_entry_link_tags('mod_document_action_buttons_group') }}
{% endblock %}

{% block content %}

    <h1>{{ 'Calendar list' |trans }}</h1>

    {{ filterOrder|chill_render_filter_order_helper }}

    {% if calendarItems|length == 0 %}
        <p class="chill-no-data-statement">
            {% if nbIgnored == 0 %}
                {{ "There is no calendar items."|trans }}
            {% else %}
                {{ 'chill_calendar.There are count ignored calendars by date filter'|trans({'nbIgnored': nbIgnored}) }}
            {% endif %}
        </p>
    {% else %}
        {% if calendarItems|length > 0 %}
            <div class="flex-table list-records context-accompanyingCourse">
                {% for calendar in calendarItems %}
                    {{ include('@ChillCalendar/Calendar/_list.html.twig', {context: 'accompanying_course'}) }}
                {% endfor %}
            </div>

            {% if calendarItems|length < paginator.getTotalItems %}
                {{ chill_pagination(paginator) }}
            {% endif %}

        {% endif %}
    {% endif %}

    <ul class="record_actions sticky-form-buttons">
        {% if accompanyingCourse.user is not same as(null) %}
            <li>
                <a href="{{ path('chill_calendar_calendar_new', {'user_id': user_id, 'accompanying_period_id': accompanying_course_id, 'mainUser': accompanyingCourse.user.id }) }}"
                   class="btn btn-create">
                    {{ 'chill_calendar.Create for referrer'|trans }}
                </a>
            </li>
        {% endif %}
        <li>
            <a href="{{ path('chill_calendar_calendar_new', {'user_id': user_id, 'accompanying_period_id': accompanying_course_id}) }}"
               class="btn btn-create">
                {{ 'Create'|trans }}
            </a>
        </li>
    </ul>

{% endblock %}
