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

{% block title %}{% trans "Weight log for workout" %}{% endblock %}

{% block header %}

<script type="text/javascript">
// Initialise the datepicker for the modal dialog
function custom_modal_init()
{
    init_weight_log_datepicker();
}
</script>
{% endblock %}

{% block content %}
{% if workout.comment %}
<p>
    <strong>{% trans "Goal" %}:</strong> {{workout.comment}}
</p>
{% endif %}

{% for day in workout.canonical_representation.day_list %}
    <h3>{{ day.obj.description }}</h3>

    <p>
    <a href="{% url 'day-log' day.obj.id %}"
       title="{% trans 'Add weight log to this day' %}">
           <img src="{% static 'images/icons/statistics.svg' %}"
                width="32"
                height="32"
                alt="{% trans 'Add weight log to this day' %}">
        {% trans 'Add weight log to this day' %}
    </a>
    </p>

    {% for set in day.set_list %}
    {% for exercise in set.exercise_list %}

        {% with day_list=workout_log|get_item:day.obj.id %}
        {% with exercise_list=day_list|get_item:exercise.obj.id %}

            <div class="alert alert-info" style="text-align: center;margin-top:1em;">
                <a href="{{ exercise.obj.get_absolute_url }}">{{ exercise.obj.name }}</a>
            </div>

            {% if exercise_list.log_by_date %}
                {% with list=exercise_list.log_by_date %}
                    {% render_weight_log list exercise_list.div_uuid %}

                    <script>
                    $(document).ready(function() {
                    weight_log_chart({{exercise_list.chart_data|safe}}, "{{exercise_list.div_uuid}}", "{{reps}}")
                    });
                    </script>
                {% endwith %}
            {% else %}
                <p><em>{% trans "No weight entries here." %}</em></p>
            {% endif %}

        {% endwith %}
        {% endwith %}

    {% empty%}
    <p>
        <em>{% trans "No exercises for this day." %}</em>
    </p>
    {% endfor %}
    {% endfor %}
{% endfor %}
{% endblock %}



<!--
        Side bar
-->
{% block sidebar %}
<h3>{% trans "Options" %}</h3>
<p>
<a href="{% url 'workout-view' workout.id %}">
    <img src="{% static 'images/icons/list.svg' %}"
         width="32"
         height="32"
         alt="{% trans 'Back to workout' %}">
    {% trans "Back to workout" %}
</a>
</p>

<h3>{% trans "Notes" %}</h3>
<p>{% blocktrans %}This page shows the weight logs belonging to this workout
only. Click on an exercise to see all the historical data for
it.{% endblocktrans %}</p>

<p>{% blocktrans %}Click on a value on a chart to edit the log
entry.{% endblocktrans %}</p>

<p>{% blocktrans %}If on a single day there is more than one entry with the
same number of repetitions, but different weights, only the entry with the
higher weight is shown in the diagram.{% endblocktrans %}</p>

{% endblock %}
