{% extends 'garpixcms/base.html' %}

{% block content %}
    <h1>{{ object.title }}</h1>

    <form method="get" action="">
        <div class="form-group">
            <label for="to">Период</label>
            <select name="filter_dates">
                <option value="1">Последняя неделя</option>
                <option value="3" {% if filter_dates == 3 %}selected{% endif %}>Текущий месяц</option>
                <option value="4" {% if filter_dates == 4 %}selected{% endif %}>Прошлый месяц</option>
                <option value="2" {% if filter_dates == 2 %}selected{% endif %}>Свой период</option>
            </select>
        </div>
        <div class="form-group">
            <label for="from">Дата начала периода</label>
            <input type="date" class="form-control" name="from" id="from" value="{{ date_from|date:"Y-m-d" }}"
                   placeholder="Дата начала периода">
        </div>
        <div class="form-group">
            <label for="to">Дата конца периода</label>
            <input type="date" class="form-control" name="to" id="to" value="{{ date_to|date:"Y-m-d" }}"
                   placeholder="Дата конца периода">
        </div>
        <div class="form-group">
            <label for="to">Специализация</label>
            <select name="filter_specialization_id">
                <option value="">Все</option>
                {% for specialization in specializations %}
                    <option value="{{ specialization.id }}" {% if specialization.id == filter_specialization_id %}selected{% endif %}>{{ specialization.title }}</option>
                {% endfor %}
            </select>
        </div>
        <button type="submit" class="btn btn-primary">Применить</button>
    </form>

    <div style="overflow-x: scroll;">
        <table border="1" style="margin: 10px;">
            <thead>
            <tr>
                <th>ФИО</th>
                <th>Специализация</th>
                <th>Итого за период</th>
                {% for date in dates %}
                    <th>{{ date|date:"d.m.Y" }}</th>
                {% endfor %}
            </tr>
            </thead>
            <tbody>
            {% for row in data %}
                <tr>
                    {% for col in row %}
                        <td>
                            {% if forloop.counter > 3 %}
                                {% if col.value == 0 %}
                                    {% if col.is_weekend %}
                                        <div style="background: black;">{% include 'garpix_jira/include/worklog_table_cell.html' with cell=col %}</div>
                                    {% else %}
                                        <div style="background: red;">{% include 'garpix_jira/include/worklog_table_cell.html' with cell=col %}</div>
                                    {% endif %}
                                {% else %}
                                    {% if col.value > 6 %}
                                        <div>{% include 'garpix_jira/include/worklog_table_cell.html' with cell=col %}</div>
                                    {% else %}
                                        <div style="background: yellow;">{% include 'garpix_jira/include/worklog_table_cell.html' with cell=col %}</div>
                                    {% endif %}
                                {% endif %}
                            {% else %}
                                {{ col }}
                            {% endif %}
                        </td>
                    {% endfor %}
                </tr>
            {% endfor %}
            </tbody>
        </table>
    </div>

{% endblock %}