{% extends "base.html" %}
{% load i18n %}
{% load staticfiles %}
{% load wger_extras %}

{% block title %}{% trans "Dashboard" %}{% endblock %}

{% block header %}
{% endblock %}



{% block content %}
{% if current_workout %}
<div class="modal fade" id="calendar-day-select-popup">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title">{% trans 'Add log to day' %}</h4>
            </div>
            <div class="modal-body">
                {% if current_workout %}
                <p>{% blocktrans %}Click to add weight logs to a training
day in your current workout:{% endblocktrans %} <strong>{{current_workout}}</strong></p>

                {% for day in current_workout.day_set.all %}
                    <a href="{% url 'manager:day:log' day.pk %}" class="btn btn-block btn-default">{{day.description}}</a>
                {% endfor %}

                {% else %}
                <p><em>{% trans "No workouts found." %}</em></p>
                <p>
                <a href="{% url 'manager:workout:add' %}" class="btn btn-block btn-default">
                   <img src="{% static 'images/icons/add.svg' %}"
                        width="22"
                        height="22"
                        alt="">
                    {% trans "Add one now." %}
                </a>
                </p>
                {% endif %}
            </div>
        </div>
    </div>
</div>
{% endif %}

<div class="row">
    <div class="col-sm-6">
        <h4>{% trans "Workout"%}</h4>

        {% if current_workout %}
            <p>
            <a href="{{ current_workout.get_absolute_url }}">
                {% if current_workout.comment %}
                    {{ current_workout.comment }}
                {% else %}
                    {% trans "Workout" %}
                {% endif %}
            </a>
            </p>
             – {{ current_workout.creation_date }}

            <ul>
                {% for day, exercise, is_workout in weekdays %}
                <li>
                    {% if not is_workout %}<span class="text-muted">{% endif%}
                    {{ day }}:

                    {{ exercise }}
                    {% if not is_workout %}</span>{% endif%}

                </li>
                {% endfor %}
            </ul>

            {% if current_workout.day_set.all %}
                <p><a href="#" id="logging-popup-link" data-toggle="modal" data-target="#calendar-day-select-popup">{% trans "Add new log" %}</a></p>
            {% endif %}

            {% if schedule %}
                <p>
                    → {% trans "This workout is part of a schedule:" %}
                    <a href="{{schedule.get_absolute_url}}">{{schedule.name}}</a>
                </p>
            {% endif %}

        {% else %} {# no workout #}
            <a href="{% url 'manager:workout:add' %}" class="btn btn-block btn-default">
            {% trans "No workouts found." %} {% trans "Add one now." %}
            </a>
        {% endif %}

    </div>
    <div class="col-sm-6">
        <h4>{% trans "Nutrition plan"%}</h4>

        {% if plan %}
            <p>
            <a href="{{ plan.get_absolute_url }}">{{ plan }}</a>
            </p>
            – {{ plan.creation_date }}
            <ul>
                <li>
                    {% trans "Energy" %}: {{nutritional_info.total.energy|floatformat}} {% trans "kcal" %}
                </li>
                <li>
                    {% trans "Protein" %}: {{nutritional_info.total.protein|floatformat}} {% trans_weight_unit 'g' user %}
                </li>
                <li>
                    {% trans "Carbohydrates" %}: {{nutritional_info.total.carbohydrates|floatformat}} {% trans_weight_unit 'g' user %}
                </li>
                <li>
                    {% trans "Fat" %}: {{nutritional_info.total.fat|floatformat}} {% trans_weight_unit 'g' user %}
                </li>
            </ul>

        {% else %}
            <p>
                <a href="{% url 'nutrition:plan:add' %}" class="btn btn-block btn-default">
                {% trans "No nutrition plans." %} {% trans "Add one now." %}
                </a>
            </p>
        {% endif %}
        {% if weight %}
        <p>
            {% trans "Your current weight is: "%}
            <strong>
                {{weight.weight|floatformat}} {% trans_weight_unit 'kg' user %}
            </strong>
        </p>
        {% endif %}
    </div>
</div>

<div class="row">
    <div class="col-sm-6">
        <p>
            <a href="{% url 'manager:workout:add' %}">
            <img src="{% static 'images/icons/new.svg' %}"
                 width="32"
                 height="32"
                 alt="{% trans 'Add workout' %}"
                 title="{% trans 'Add workout' %}">
            {% trans "Add workout" %}</a>
        </p>
    </div>
    <div class="col-sm-6">
        <p>
            <a href="{% url 'nutrition:plan:add' %}">
            <img src="{% static 'images/icons/new.svg' %}"
                 width="32"
                 height="32"
                 alt="{% trans 'Add nutrition plan' %}"
                 title="{% trans 'Add nutrition plan' %}">
                {% trans "Add nutrition plan" %}</a>
        </p>
    </div>
</div>
{% endblock %}



{% block sidebar %}
<h4>{% trans "Info" %}</h4>
<p>{% blocktrans %}The current workout is selected from your active schedule
or, if you don't have one, simply by date.{% endblocktrans %}</p>

<p>{% trans "After adding a workout or a nutritional plan, you can edit them to set a goal." %}
</p>
{% endblock %}
