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

{% comment %}{% block head_base_js %}{{ block.super }}
<script language="JavaScript">
//<![CDATA[
$('td.item').click(function(e) {
    return;
});
//]]>
</script>
{% endblock %}{% endcomment %}

{% block datebook_container_css_classes %} large-row-fluid{% endblock %}

{% block datebook_content %}
<div class="clearfix">
    <ul class="inline-list right">
        <li><a href="#">Calendar view</a></li>
        <li><a href="#">Flat view</a></li>
    </ul>
</div>

<div class="datebook-month calendar">
    <div class="head">
        {% spaceless %}
            <span class="weekno"></span>
            {% for classname, name in datebook_calendar.weekheader %}
            <span class="{% cycle 'mon' 'tue' 'wed' 'thu' 'fri' 'sat' 'sun' %}">{% trans name %}</span>
            {% endfor %}
        {% endspaceless %}
    </div>
    
    {% spaceless %}
    {% for week in datebook_calendar.month %}
    <div class="week">
        <div class="item weekno">
            <span class="label radius">Week&nbsp;{{ forloop.counter }}</span>
        </div>
        {% for day in week %}
            {% cycle 'mon' 'tue' 'wed' 'thu' 'fri' 'sat' 'sun' as day_name silent %}
            <div class="item {{ day_name }}{% if day.entry %} has-entry{% if day.entry.vacation %} vacation{% endif %}{% endif %}{% if day.is_current %} current{% endif %}{% if day.noday %} noday{% endif %}"
            {% if not day.noday %} data-date="{{ day.date.day }}"{% endif %}>
                {% if not day.noday %}
                    <h3>{{ day.date|date:"l d F" }}</h3>
                    <div class="container">
                        {% if day.entry %}
                            {% if day.entry.vacation %}
                                <p class="vacation-label">Vacation</p>
                            {% else %}
                                <p class="working-hour">{{ day.entry.get_working_hours }}</p>
                                {% if day.entry.content %}
                                    <div class="content">{{ day.entry.content|linebreaks }}</div>
                                {% else %}
                                    <p class="empty">Empty content</p>
                                {% endif %}
                                {% comment %}<p class="length">{{ day.entry.get_elapsed_time }}</p>{% endcomment %}
                            {% endif %}
                        {% else %}
                        <p class="empty">There is no entry yet, <a href="{% url 'datebook-author-day-add' author=author year=datebook.period.year month=datebook.period.month day=day.date.day %}">add one</a></p>
                        {% endif %}
                    </div>
                    <div class="menu">
                        {% if day.entry %}
                            <a title="{% trans 'Read' %}" class="read action" href="#">
                                <i class="icon-eye"></i>
                            </a> 
                            <a title="{% trans 'Edit' %}" class="edit action" href="{% url 'datebook-author-day-edit' author=author year=datebook.period.year month=datebook.period.month day=day.date.day %}">
                                <i class="icon-pencil"></i>
                            </a>
                        {% else %}
                            <a title="{% trans 'Add' %}" class="add action" href="{% url 'datebook-author-day-add' author=author year=datebook.period.year month=datebook.period.month day=day.date.day %}">
                                <i class="icon-add-circle"></i>
                            </a> 
                        {% endif %}
                    </div>
                {% endif %}
            </div>
        {% endfor %}
    </div>
    {% endfor %}
    {% endspaceless %}
    
</div>
{% endblock %}
