{% extends 'main/temp.html' %}
{% load static %}
{% load set_var %}

{% block maincontent %}
<section class="main-content workout-main-content" id="main-content">
	<h1 class="page-title">Программа тренировок</h1>
	{% if user.is_authenticated %}
		{% if tw1 and tw2 %}
			<table id='wt1' class="workout-table" style="display:block">
				{% if tw1 %}
					{% with '0' as prevdate %}
							{% for row in tw1 %}
								{% if forloop.first %}
									<tr>
										<td class="table-head-top" colspan="5">
											<b>{{ row.week }}</b>
										</td>
									</tr>
									<tr class="odd">
										<td class="exercise-head" id="exercise-head">
											<strong>Упражнение</strong>
										</td>
										<td class="muscle-group-head" id="muscle-group-head">
											<strong>Группа мышц</strong>
										</td>
										<td class="count-head" id="count-head">
											<strong>Время/подходы</strong>
										</td>
										<td class="leha" id="leha">
											<strong>Вес</strong>
										</td>
									</tr>
								{% endif %}
								{% if prevdate == row.date %}
								{% else %}
									<tr>
										<td class="table-head" colspan="5">
											<b class="day-name">[{{row.date}}] {{row.day_name}}</b>
										</td>
									</tr>
									{% update_variable row.date as prevdate %}
								{% endif %}
								<tr class="{% if forloop.counter|divisibleby:2 %}odd{% else %}even{% endif %}">
									<td class="exercise">{{ row.exercise }}</td>
									<td class="muscle-group">{{ row.muscle_group_name }}</td>
									<td class="count">{{ row.sets_count }}</td>
									<td class="l-prim">{{ row.weigth }}</td>
								</tr>
								{% update_variable row.date as prevdate %}
						{% endfor %}
					{% endwith %}
				{% else %}
					<tr>
						<td>Записей нет</td>
					</tr>
				{% endif %}
			</table>
			<br>
			<table id='wt2' class="workout-table" style="display: block">
				{% if tw2 %}
					{% with '0' as prevdate %}
							{% for row in tw2 %}
								{% if forloop.first %}
									<tr>
										<td class="table-head-top" colspan="5">
											<b>{{ row.week }}</b>
										</td>
									</tr>
									<tr class="odd">
										<td class="exercise-head" id="exercise-head">
											<strong>Упражнение</strong>
										</td>
										<td class="muscle-group-head" id="muscle-group-head">
											<strong>Группа мышц</strong>
										</td>
										<td class="count-head" id="count-head">
											<strong>Время/подходы</strong>
										</td>
										<td class="leha" id="leha">
											<strong>Вес</strong>
										</td>
									</tr>
								{% endif %}
								{% if prevdate == row.date %}
								{% else %}
									<tr>
										<td class="table-head" colspan="5">
											<b class="day-name">[{{row.date}}] {{row.day_name}}</b>
										</td>
									</tr>
									{% update_variable row.date as prevdate %}
								{% endif %}
								<tr class="{% if forloop.counter|divisibleby:2 %}odd{% else %}even{% endif %}">
									<td class="exercise">{{ row.exercise }}</td>
									<td class="muscle-group">{{ row.muscle_group_name }}</td>
									<td class="count">{{ row.sets_count }}</td>
									<td class="l-prim">{{ row.weigth }}</td>
								</tr>
								{% update_variable row.date as prevdate %}
						{% endfor %}
					{% endwith %}
				{% else %}
					<tr>
						<td>Записей нет</td>
					</tr>
				{% endif %}
			</table>
		{% else %}
			<p class="content-text">Записей нет</p>
		{% endif %}
	{% else %}
		<p class="content-text">Для просмотра информации войдите или зарегистрируйтесь!</p>
	{% endif %}
</section>
{% endblock %}
{% block titletext %}Dhaverd - Workout{% endblock %}

{% block javascripts %}
<script src="{% static 'main/src/scripts/jquery.min.js' %}"></script>
<script src="{% static 'main/src/scripts/workout.js' %}"></script>
{% endblock %}