{% extends 'timepiece/schedule/base.html' %}
{% load url from future %}
{% load bootstrap_toolkit %}

{% block title %}Schedule for the Week of {{ week|date:'M j, Y' }}{% endblock title %}

{% block bodyid %}project-hours{% endblock bodyid %}

{% block extrajs %}
    <script charset="utf-8" src="{{ STATIC_URL }}timepiece/js/highlight.js"></script>
    <script>
        $(function() {
            hover_highlight('#schedule');
        });
    </script>
{% endblock extrajs %}

{% block content %}
    <div class="row-fluid">
        <div class="span12">
            <h2>Schedule for the Week of {{ week|date:'M j, Y'}}</h2>
            <ul class="nav nav-pills">
                <li><a href="{% url 'view_schedule' %}?week_start={{ prev_week|date:'Y-m-d' }}">&larr; Prev Week</a></li>
                <li><a href="{% url 'view_schedule' %}?week_start={{ next_week|date:'Y-m-d' }}">Next Week &rarr;</a></li>
            </ul>
        </div>
    </div>

    <div class="row-fluid">
        <div class="span10">
            <form class="form-inline" accept-charset="UTF-8" method="get" action="">
                {{ form|as_bootstrap:"inline" }}
                <button type="submit" class="btn" name="submit">Update</button>
            </form>
        </div>
        {% if perms.entries.add_projecthours %}
            <div class="span2">
                <a class="btn right" href="{% url 'edit_schedule' %}?week_start={{ week|date:'Y-m-d' }}">Edit Schedule</a>
            </div>
        {% endif %}
    </div>

    <div class="row-fluid">
        <div class="span12">
            {% if projects %}
                <table id="schedule" class="table table-striped table-bordered table-condensed">
                    <thead>
                        <tr>
                            <th>Project</th>
                            {% for id, first_name, last_name in users %}
                                <th>{{ first_name }} {{ last_name|first }}.</th>
                            {% endfor %}
                        </tr>
                    </thead>
                    <tbody>
                        {% for id, name, entries in projects %}
                            <tr>
                                <th>{{ name }}</th>
                                {% for entry in entries %}
                                    <td class="hours{% if not entry.published %} unpublished{% endif %}">
                                        {% if entry.hours %}{{ entry.hours|floatformat:0 }}{% endif %}
                                    </td>
                                {% endfor %}
                            </tr>
                        {% endfor %}
                    </tbody>
                </table>
            {% else %}
                <p>There are no entries this week.</p>
            {% endif %}
        </div>
    </div>
{% endblock content %}
