{% extends "datebook/base.html" %}
{% load i18n %}

{% block datebook_content %}
<div class="datebook-calendar-year">{% for month_date, month_datebook in datebooks_map %}
    <div class="flex-column radius text-center{% if not month_datebook %} empty{% endif %}{% if month_date.year == today.year and month_date.month == today.month %} current{% endif %}">
        <div class="inner">
            <h3>{{ month_date|date:"F" }}</h3>
            {% if month_datebook %}
                <p>
                    {% with month_datebook.dayentry_set.count as entries_counter %}
                    <a href="{% url 'datebook:month-detail' author=author year=month_datebook.period.year month=month_datebook.period.month %}" class="button{% if not entries_counter %} secondary{% endif %}">
                        {% if entries_counter > 0 %}
                            {% blocktrans count counter=entries_counter %}{{ counter }} day{% plural %}{{ counter }} days{% endblocktrans %}
                        {% else %}
                            {% trans "Empty" %}
                        {% endif %}
                    </a>
                    {% endwith %}
                </p>
            {% else %}
                {% if user == author or user.is_superuser or perms.datebook.add_datebook %}
                    <p><a href="#" class="button success" data-reveal-id="new-datebook-{{ month_date.month }}">{% trans "Create it" %}</a></p>
                {% else %}
                    <p class="empty text-center">{% trans "Empty" %}</p>
                {% endif %}
            {% endif %}
        </div>
    </div>
{% endfor %}</div>
{% endblock %}

{% block foot_more_js %}{{ block.super }}{% if user == author or user.is_superuser or perms.datebook.add_datebook %}
{% for month_date, month_datebook in datebooks_map %}{% if not month_datebook %}
<div id="new-datebook-{{ month_date.month }}" class="reveal-modal text-center tiny" data-reveal>
    <h3>{% trans "Create a new datebook" %}</h3>
    <p>{% blocktrans with name=month_date|date:"F" year=month_date.year %}This will create a datebook for <strong>{{ name }} {{ year }}</strong>, confirm this.{% endblocktrans %}</p>
    <p><a href="{% url 'datebook:month-add' author=author year=year month=forloop.counter %}" class="radius success button">{% trans "I confirm" %}</a></p>
    <a class="close-reveal-modal">&#215;</a>
</div>
{% endif %}{% endfor %}
{% endif %}{% endblock %}