{% load i18n calendar %}

{% if calendar_days.has_other_pages %}
<p class="paginator">

{% if calendar_days.has_previous %}
<a class="previous calchunk" href="?chunk_{{ cell.pk }}={{ calendar_days.previous_page_number }}" data-content-url="{% url 'ajax-calendar-content' pk=cell.pk %}?chunk_{{cell.pk}}={{ calendar_days.previous_page_number }}">{% trans "previous" %}</a>
{% else %}
<span class="previous">{% trans "previous" %}</span>
{% endif %}
<span class="current">
    {{ calendar_days.number }} / {{ calendar_days.paginator.num_pages }}
</span>
{% if calendar_days.has_next %}
<a class="next calchunk" href="?chunk_{{ cell.pk }}={{ calendar_days.next_page_number }}" data-content-url="{% url 'ajax-calendar-content' pk=cell.pk %}?chunk_{{cell.pk}}={{ calendar_days.next_page_number }}">{% trans "next" %}</a>
{% else %}
<span class="next">{% trans "next" %}</span>
{% endif %}
</p>
{% endif %}

{% if calendar_days %}
<form method="POST" action="{% url 'calendar-booking' pk=cell.pk %}?chunk_{{cell.pk}}={{calendar_days.number}}">
    {% csrf_token %}
    <table id="cal-table-{{cell.pk}}">
        <thead>
            <tr>
                <th></th>
                {% for day in calendar_days %}
                <th>{{day|date:"SHORT_DATE_FORMAT"}}</th>
                {% endfor %}
            </tr>
        </thead>
        <tbody>
            {% for slot in calendar_slots %}
            <tr>
                <th>{{slot|date:"TIME_FORMAT"}}</th>
                {% for day in calendar_days %}
                {% get_day_slot calendar day=day slot=slot as value %}
                {% if not value.exist %}
                <td class="absent"></td>
                {% elif value.available %}
                <td class="available"></td>
                {% else %}
                <td class="unavailable"></td>
                {% endif %}
                {% endfor %}
            </tr>
            {% endfor %}
        </tbody>
    </table>
</form>
{% endif %}
