<h1>{{ "Calendar"|trans }}</h1>
<h2>
    {% if entity.endDate.diff(entity.startDate).days >= 1 %}
        {{ "From the day"|trans }} {{ entity.startDate|format_datetime('medium', 'short') }}
        {{ "to the day"|trans }} {{ entity.endDate|format_datetime('medium', 'short') }}
    {% else %}
        {{ entity.startDate|format_date('full') }},
        {{ entity.startDate|format_datetime('none', 'short', locale='fr') }} - {{ entity.endDate|format_datetime('none', 'short', locale='fr') }}
    {% endif %}
</h2>

<dl class="chill_view_data">
    <dt class="inline">{{ 'main user concerned'|trans }}</dt>
    <dd>{{ entity.mainUser }}</dd>
</dl>

<h2 class="chill-red">{{ 'Concerned groups calendar'|trans }}</h2>
{% include '@ChillActivity/Activity/concernedGroups.html.twig' with {'context': 'calendar_' ~ context, 'render': 'bloc' } %}


<h2 class="chill-red">{{ 'Calendar data'|trans }}</h2>

    {% if entity.endDate.diff(entity.startDate).days >= 1 %}
        <dt>{{ "From the day"|trans }} {{ entity.startDate|format_datetime('medium', 'short') }}
        {{ "to the day"|trans }} {{ entity.endDate|format_datetime('medium', 'short') }}
        </dt>
        <dd></dd>
    {% else %}
        <dt>
        {{ entity.startDate|format_date('full') }},
        {{ entity.startDate|format_datetime('none', 'short', locale='fr') }} - {{ entity.endDate|format_datetime('none', 'short', locale='fr') }}
        </dt>
        <dd></dd>
    {% endif %}

    <dt class="inline">{{ 'cancel reason'|trans }}</dt>
    <dd>
    {% if entity.cancelReason is not null %}
    {{ entity.cancelReason.canceledBy|localize_translatable_string }}
    {% else %}
    <span class="chill-no-data-statement">{{ 'Unknown'|trans }}</span>
    {% endif %}
    </dd>

    <dt class="inline">{{ 'status'|trans }}</dt>
    <dd>{{ entity.status }}</dd>


    <dt class="inline">{{ 'calendar location'|trans }}</dt>
    <dd>
        {% if entity.location is not null %}
            <p>
                {{ entity.location.name }}
                <span> ({{ entity.location.locationType.title|localize_translatable_string }})</span>
            </p>
            {{ entity.location.address|chill_entity_render_box }}
        {% else %}
            <span class="chill-no-data-statement">{{ 'No address given'|trans }}</span>
        {% endif %}
    </dd>

    {% if not entity.comment.isEmpty %}
    <dt class="inline">{{ 'calendar comment'|trans }}</dt>
    <dd>{{ entity.comment|chill_entity_render_box }}</dd>
    {% endif %}

    <dt class="inline">{{ 'sendSMS'|trans }}</dt>
    <dd>
    {% if entity.sendSMS is not null %}
        {% if entity.sendSMS %}{{ 'Yes'|trans }}{% else %}{{ 'No'|trans }}{% endif %}
    {% else %}
        <span class="chill-no-data-statement">{{ 'Unknown'|trans }}</span>
    {% endif %}
    </dd>


</dl>

{% set accompanying_course_id = null %}
{% if accompanyingCourse %}
    {% set accompanying_course_id = accompanyingCourse.id %}
{% endif %}

{% set user_id = null %}
{% if user %}
    {% set user_id = user.id %}
{% endif %}

<ul class="record_actions sticky-form-buttons">
    <li class="cancel">
        <a class="btn btn-cancel" href="{{ chill_return_path_or('chill_calendar_calendar_list_by_period',
            { 'id': accompanying_course_id }) }}">
            {{ 'Back to the list'|trans }}
        </a>
    </li>
    <li>
        <a class="btn btn-create" href="{{ chill_path_add_return_path('chill_activity_activity_new',
            { 'accompanying_period_id': accompanying_course_id, 'activityData': activityData }) }}">
            {{ 'Transform to activity'|trans }}
        </a>
    </li>
    {% if accompanyingCourse %}
    <li>
        <a class="btn btn-update" href="{{ path('chill_calendar_calendar_edit',
            { 'id': entity.id, 'accompanying_period_id': accompanying_course_id }) }}">
            {{ 'Edit'|trans }}
        </a>
    </li>
    {% endif %}
    {% if user %}
    <li>
        <a class="btn btn-update" href="{{ path('chill_calendar_calendar_edit', { 'id': entity.id, 'user_id': user_id }) }}">
            {{ 'Edit'|trans }}
        </a>
    </li>
    {% endif %}
    {# TODO
    {% if is_granted('CHILL_ACTIVITY_DELETE', entity) %}
    #}

    <li>
        <a href="{{ path('chill_calendar_calendar_delete', { 'id': entity.id, 'accompanying_period_id': accompanying_course_id, 'user_id': user_id } ) }}" class="btn btn-delete">
            {{ 'Delete'|trans }}
        </a>
    </li>

    {#
    {% endif %}
    #}
</ul>
