{% extends "base.html" %}
{% load i18n %}
{% activetab "main" "time" %}

{% block page-title %}{% trans "Weekly view" %}{% endblock %}

{% block navigation %}
  {% activetab "main" "time" %}
  {{ block.super }}
{% endblock %}

{% block sub-navigation %}
  <ul>
    <li><a href="{% url inhouse.views.show_today %}">{% trans "Current day" %}</a></li>
    <li><a href="{% url inhouse.views.overview %}">{% trans "Overview" %}</a></li>
    <li><a href=""><strong>{% trans "Weekly view" %}</strong></a></li>
    <li><a href="">{% trans "Month" %}</a></li>
  </ul>
{% endblock %}

{% block content %}
  <div id="week" class="default-list">
    <div class="pagination">
      <div style="margin-bottom: 5px; float:left;">
        <a title="{% trans "previous week" %}" href="/time/week/{{ previous_day|date:"Y/m/d" }}"><span class="sprite left_big"></span></a>
        <a title="{% trans "next week" %}" href="/time/week/{{ next_day|date:"Y/m/d" }}"><span class="sprite right_big"></span></a>
        {{ first_day|date }} - {{ last_day|date }}
      </div>
    </div>
    <table width="100%" style="table-layout:fixed;">
      <thead>
        <tr>
          {% for day in days %}
            <th style="text-align: center;">
            <a href="/time/{{ day|date:"Y/m/d" }}">{{ day|date:"D" }} {{ day|date:"SHORT_DATE_FORMAT" }}</a>
            </th>
          {% endfor %}
        </tr>
      </thead>
      <tbody>
          <tr>
            {% for date, bookings in day_data %}
              <td class="week_day{% ifequal date today %} current{% endifequal %}">
                {% if bookings %}
                  <table>
                  {% for booking in bookings %}
                    <tr style="border-bottom: 3px solid {% ifequal date today %}#FFF7D7{% else %}white{% endifequal %};">
                      <td class="week_booking" style="height:{{ booking.duration|duration_to_pixel }}px; {% if booking.is_closed %} background-color: #DDD;{% endif %}">
                        {{ booking.duration|format_minutes_to_time }}<br/>
                        <a href="/time/edit/{{ booking.id }}">{{ booking.get_title|truncatewords:20 }}</a>
                      </td>
                    </tr>
                    <!--<tr style="border-bottom: none; background: none;"><td></td></tr>-->
                  {% endfor %}
                  </table>
                {% endif %}
              </td>
            {% endfor %}
          </tr>
          <tr class="sum">
            <!--<td width="30px;"><strong>{% trans "Sum:" %}</strong></td>-->
            {% for sum in sum_data %}
              <td style="text-align: center;"><strong>{% if sum %}{{ sum|format_minutes_to_time }}{% else %}----{% endif %}</strong></td>
            {% endfor %}
          </tr>
          <tr>
            <th colspan="7" style="text-align: center;"><strong>{% if week_sum %}{{ week_sum|format_minutes_to_time }}{% else %}----{% endif %}</strong></td>
          </tr>
      </tbody>
    </table>
  </div>
{% endblock %}
