{% extends 'layout.html' %}
{% load crispy_forms_tags %}
{% block content %}

    <div class="row mb-3">
        <div class="col-sm-12 col-md-12 col-lg-6 text-sm-center text-lg-start">
            <h2>{{ user.first_name | title }} {{ user.last_name | title }}</h2>
        </div>
        <div class="col-sm-12 col-md-12 col-lg-6 text-sm-center text-lg-end">
            {% if user.level == '3' %}
            <a href="#!" class="btn btn-lg btn-secondary"><span class="oi" data-glyph="wrench"></span></a>
            {% endif %}
            <a href="#!" class="btn btn-lg btn-secondary"><span class="oi" data-glyph="document"></span></a>
            <a href="{% url 'logout' %}" class="btn btn-lg btn-danger"><span class="oi" data-glyph="account-logout"></span></a>
        </div>
    </div>
    <div class="row mb-3">
        <div class="col-12">
            <div class="card">
                <div class="card-body">
                    {% include 'forms/timesheet_entry.html' %}
                </div>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-12">
            <div class="card">
                <div class="card-body">
                    <div class="row mb-3 border-bottom">
                        <div class="col-sm-6">
                            <h3>Total Time Worked</h3>
                        </div>
                        <div class="col-sm-6">
                            <h3>{{ total_time_worked }}</h3>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-4">
                            <b>Date</b>
                        </div>
                        <div class="col-4">
                            <b>Time Worked</b>
                        </div>
                        <div class="col-4">
                            <b>Project</b>
                        </div>
                    </div>
                    {% for entry in entries %}
                        <div class="row report-row p-3">
                            <div class="col-sm-12 col-md-4">
                                {{ entry.date }}
                            </div>
                            <div class="col-sm-6 col-md-4">
                                {{ entry.time_worked }}
                            </div>
                            <div class="col-sm-6 col-md-4">
                                {% if entry.project %}
                                    {{ entry.project.name }}
                                {% else %}
                                    -
                                {% endif %}
                            </div>
                        </div>
                    {% endfor %}
                </div>
            </div>
        </div>
    </div>

{% endblock %}