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

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


{% block content %}
<div class="modal fade" id="current-workout">
    <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 "Current workout" %}</h4>
                {% if current_workout %}
                    <h5><a href="{{ current_workout.get_absolute_url }}">{{ current_workout }}</a></h5>
                {% endif %}
            </div>
            <div class="modal-body">
                {% if current_workout %}

                <ul class="list-group">
                    {% for day, exercises, is_workout in weekdays %}
                    <li class="list-group-item">
                        <span {% if not is_workout %}class="text-muted"{% endif%}>
                        {{ day }}: {{ exercises }}
                        </span>
                    </li>
                    {% endfor %}
                </ul>
                {% if schedule %}
                <p>
                    → {% trans "This workout is part of a schedule:" %}
                    <a href="{{schedule.get_absolute_url}}">{{schedule.name}}</a>
                </p>
                {% endif %}
                {% endif %}
            </div>
            <div class="modal-footer">
              <button type="button" class="btn btn-default" data-dismiss="modal">{% trans "Close" %}</button>
            </div>
        </div>
    </div>
</div>



<div class="modal fade" id="current-nutrition-plan">
    <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 "Current nutrition plan" %}</h4>
                {% if plan %}
                <h5><a href="{{ plan.get_absolute_url }}">{{ plan }}</a></h5>
                {% endif %}
            </div>
            <div class="modal-body">
                {% if plan %}
                <ul class="list-group">
                    <li class="list-group-item">
                        {% trans "Energy" %}: {{nutritional_info.total.energy|floatformat}} {% trans "kcal" %}
                    </li>
                    <li class="list-group-item">
                        {% trans "Protein" %}: {{nutritional_info.total.protein|floatformat}} {% trans_weight_unit 'g' user %}
                    </li>
                    <li class="list-group-item">
                        {% trans "Carbohydrates" %}: {{nutritional_info.total.carbohydrates|floatformat}} {% trans_weight_unit 'g' user %}
                    </li>
                    <li class="list-group-item">
                        {% trans "Fat" %}: {{nutritional_info.total.fat|floatformat}} {% trans_weight_unit 'g' user %}
                    </li>
                </ul>

                {% if weight %}
                <p>
                    {% trans "Your current weight is: "%}
                    <strong>
                        {{weight.weight|floatformat}} {% trans_weight_unit 'kg' user %}
                    </strong>
                </p>
                {% endif %}

                {% endif %}
            </div>
            <div class="modal-footer">
              <button type="button" class="btn btn-default" data-dismiss="modal">{% trans "Close" %}</button>
            </div>
        </div>
    </div>
</div>

<div class="modal fade" id="timer-current-workout">
    <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 "Start gym mode" %}</h4>
                <h5></h5>
            </div>
            <div class="modal-body">
                <p>{% blocktrans %}Use the gym mode to
start an interactive training session. If you enter lifted weights, they will
be added to your workout log. A timer between sets helps you keep track of the
pauses you do.{% endblocktrans %}</p>
                <p>
                    <strong>{% trans "Tip:" %}</strong>
                    {% blocktrans %}You can deactivate the timer or set
its default duration in your settings.{% endblocktrans %}
                </p>

                <div class="list-group">
                    {% if current_workout %}
                        {% for day in current_workout.canonical_representation.day_list %}
                                {% if day.set_list|length > 0 %}
                                    <a href="{% url 'manager:workout:timer' day.obj.pk %}" class="list-group-item wger-list-group-item">
                                        <span class="glyphicon glyphicon-chevron-right pull-right"></span>
                                        {{day.obj.description}}
                                    </a>
                                {% else %}
                                <span class="list-group-item">{{day.obj.description}}</span>
                                {% endif %}
                        {% empty %}
                            <a href="{% url 'manager:day:add' current_workout.id %}" class="list-group-item">
                                <span class="glyphicon glyphicon-chevron-right pull-right"></span>
                                {% trans "No days for this workout." %}<br>
                                {% trans "Add training day." %}
                                </a>
                        {% endfor %}
                    {% else %}
                        <a href="{% url 'manager:workout:add' %}" class="list-group-item">
                            <span class="glyphicon glyphicon-chevron-right pull-right"></span>
                            {% trans "No workouts found." %}<br>
                            {% trans "Add one now." %}
                        </a>
                    {% endif %}
                </div>
            </div>
            <div class="modal-footer">
              <button type="button" class="btn btn-default" data-dismiss="modal">{% trans "Close" %}</button>
            </div>
        </div>
    </div>
</div>






<a href="#timer-current-workout"
   data-toggle="modal"
   class="btn btn-default btn-block">
    <span class="{% fa_class 'play' 'lg' %}"></span>
    <br>
    {% trans "Start current workout" %}
</a>

<div class="row" style="margin-top: 1em;">
    <div class="col-xs-6" style="padding-right: 7px;">
        {% if current_workout %}
            <a href="#current-workout"
               data-toggle="modal"
               class="btn btn-default btn-block"
               style="white-space: normal;">
                <span class="{% fa_class 'list' 'lg' %}"></span>
                <br>
                {{current_workout}}
            </a>
        {% else %}
            <a href="{% url 'manager:workout:add' %}" class="btn btn-default btn-block">
                <span class="{% fa_class 'plus' 'lg' %}"></span>
                <br>
                {% trans "Workout" %}
            </a>
        {% endif %}
    </div>
    <div class="col-xs-6" style="padding-left: 7px;">
        <a href="{% url 'manager:workout:calendar' %}"
           class="btn btn-default btn-block"
           style="white-space: normal;">
            <span class="{% fa_class 'calendar' 'lg' %}"></span>
            <br>
            {% trans "Calendar" %}
        </a>

    </div>
</div>

<div class="row" style="margin-top: 1em;">
    <div class="col-xs-6" style="padding-right: 7px;">
        {% if plan %}
        <a href="#current-nutrition-plan"
           data-toggle="modal"
           class="btn btn-default btn-block"
           style="white-space: normal;">
            <span class="{% fa_class 'cutlery' 'lg' %}"></span>
            <br>
            {{plan}}
        </a>
        {% else %}
            <a href="{% url 'nutrition:plan:add' %}" class="btn btn-default btn-block">
                <span class="{% fa_class 'plus' 'lg' %}"></span>
                <br>
                {% trans "Nutrition plan" %}
            </a>
        {% endif %}
    </div>
    <div class="col-xs-6" style="padding-left: 7px;">
        <a href="{% url 'weight:overview' user.username %}" class="btn btn-default btn-block">
            <span class="{% fa_class 'line-chart' 'lg' %}"></span>
            <br>
            {% trans "Weight overview" %}
        </a>
    </div>
</div>


<div class="row" style="margin-top: 1em;">
    <div class="col-xs-6" style="padding-right: 7px;">
        <a href="{% url 'core:user:preferences' %}" class="btn btn-default btn-block">
            <span class="{% fa_class 'cogs' 'lg' %}"></span>
            <br>
            {% trans "Preferences" %}
        </a>
    </div>

    <div class="col-xs-6" style="padding-left: 7px;">
        <a href="{% url 'core:contact' %}" class="btn btn-default btn-block">
            <span class="{% fa_class 'envelope-o' 'lg' %}"></span>
            <br>
            {% trans "Get in touch" %}
        </a>
    </div>
</div>
{% endblock %}
