Jarvis/jarvis/followup/templates/heightweight/list.html

310 lines
14 KiB
HTML

{% extends "listing.html" %}
{% load has_group %}
{% load static %}
{% block datacontent %}
<div class="row justify-content-center">
<div class="col-12 col-sm-12 col-md-12 col-lg-12 col-xl-12">
<div class="card">
<div class="card-header row">
<div class="col-10 pr-0">
<h4 class="">
{% if gymnast %}
{% if gymnast.id in request.session.available_gymnast or request.user.is_superuser %}
<a href="{% url 'gymnast_details_tab' gymnast.id 'physiological' %}">
{% endif %}
{{ gymnast }}
{% if gymnast.id in request.session.available_gymnast or request.user.is_superuser %}
</a>
{% endif %}'s
{% endif %} Height/Weight
</h4>
</div>
<div class="col-2 ml-auto pl-0">
<div class="text-right">
{% if request.user|has_group:"trainer" %}
<h3 class="mb-0">
<a href="{% if gymnast %}{% url 'heightweight_create_for_gymnast' gymnast.id %}{% else %}{% url 'height_weight_create' %}{% endif %}">
<i class="fas fa-plus text-warning"></i>
</a>
</h3>
{% endif %}
</div>
</div>
</div>
<div class="card-body pt-0">
{% if gymnast %}
<div class="row">
<div class="col-md-6">
<table class="table tablesorter table-striped mb-0" data-sort="table" id="height_weight_table">
<thead>
<tr>
<th></th>
<th class="header text-left">Date</th>
<th class="header text-center">Height</th>
<th class="header text-center">Hips height</th>
<th class="header text-center">Weight</th>
<th class="header text-center">BMI</th>
</tr>
</thead>
<tbody>
{% for height_weight in height_weight_list %}
<tr>
<td>
<a href="{% url 'heightweight_update' height_weight.id %}">
<span class="tim-icons icon-pencil text-warning"></span>
</a>
</td>
<td class="text-left">{{ height_weight.date | date:"j-n-Y" }}</td>
<td class="text-center">{{ height_weight.height }}</td>
<td class="text-center">
{% if height_weight.hips_height == None %}
-
{% else %}
{{ height_weight.hips_height }}
{% endif %}
</td>
<td class="text-center">{{ height_weight.weight }}</td>
<td class="text-center">
{% if gymnast %}
{% if height_weight.bmi_quality == 2 %}
<span class="text-danger">
{% elif height_weight.bmi_quality == 1 %}
<span class="text-warning">
{% elif height_weight.bmi_quality == 0 %}
<span class="text-success">
{% endif %}
{% endif %}
<b>{{ height_weight.bmi | floatformat:2 }}</b>
{% if gymnast %}
</span>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<div class="col-md-6 pl-0 pr-0 pt-3">
<canvas id="chart_height_weight" class="chartjs" width="100%">
Your browser doesn't support canvas
</canvas>
</div>
</div>
{% else %}
{% if height_weight_list %}
<table class="table tablesorter table-striped mb-0" data-sort="table" id="height_weight_table">
<thead>
<tr>
<th></th>
<th class="header text-left">Date</th>
{% if not gymnast %}
<th class="header text-left">Gymnast</th>
{% endif %}
<th class="header text-center">Height</th>
<th class="header text-center">Hips height</th>
<th class="header text-center">Weight</th>
<th class="header text-center">BMI</th>
</tr>
</thead>
<tbody>
{% for height_weight in height_weight_list %}
<tr>
<td>
<a href="{% url 'height_weight_update' height_weight.id %}">
<span class="tim-icons icon-pencil text-warning"></span>
</a>
</td>
<td class="text-left">{{ height_weight.date | date:"j-n-Y" }}</td>
{% if not gymnast %}
<td class="text-left">
{% if gymnast.id in request.session.available_gymnast or request.user.is_superuser %}
<a href="{% url 'gymnast_details' height_weight.gymnast.id %}">
{% endif %}
{{ height_weight.gymnast }}
{% if gymnast.id in request.session.available_gymnast or request.user.is_superuser %}
</a>
{% endif %}
</td>
{% endif %}
<td class="text-center">{{ height_weight.height }}</td>
<td class="text-center">
{% if height_weight.hips_height == None %}
-
{% else %}
{{ height_weight.hips_height }}
{% endif %}
</td>
<td class="text-center">{{ height_weight.weight }}</td>
<td class="text-center">
{% if gymnast %}
{% if height_weight.bmi_quality == 2 %}
<span class="text-danger">
{% elif height_weight.bmi_quality == 1 %}
<span class="text-warning">
{% elif height_weight.bmi_quality == 0 %}
<span class="text-success">
{% endif %}
{% endif %}
<b>{{ height_weight.bmi | floatformat:2 }}</b>
{% if gymnast %}
</span>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p class="text-muted">There are no scores corresponding to your criterias</p>
{% endif %}
{% endif %}
</div>
</div>
</div>
</div>
{% endblock %}
{% block footerscript %}
<script src="{% static "js/template_users/chart_gradient_color.js" %}"></script>
<script type="text/javascript">
$(document).ready(function () {
$('[data-sort="table"]').tablesorter({
headers: {
0: { sorter: false },
},
dateFormat : "ddmmyyyy",
sortList: [[1, 1]]
});
$('#height_weight_table').DataTable({
scrollY: '50vh',
scrollCollapse: true,
paging: false,
searching: false,
ordering: false,
"bInfo" : false,
});
});
{% if height_weight_list %}
var timeFormat = 'DD-M-YYYY';
var ctx = document.getElementById("chart_height_weight").getContext("2d");
var border_color_pink = 'rgb(255, 99, 132)';
var gradient_stroke_pink = ctx.createLinearGradient(0, 230, 0, 50);
gradient_stroke_pink.addColorStop(1, 'rgba(255, 99, 132, 0.4)');
gradient_stroke_pink.addColorStop(0.75, 'rgba(255, 99, 132, 0.3)');
gradient_stroke_pink.addColorStop(0.5, 'rgba(255, 99, 132, 0.2)');
gradient_stroke_pink.addColorStop(0.25, 'rgba(255, 99, 132, 0)');
var border_color_orange = 'rgb(255, 159, 64)';
var gradient_stroke_orange = ctx.createLinearGradient(0, 230, 0, 50);
gradient_stroke_orange.addColorStop(1, 'rgba(255, 159, 64, 0.4)');
gradient_stroke_orange.addColorStop(0.75, 'rgba(255, 159, 64, 0.3)');
gradient_stroke_orange.addColorStop(0.5, 'rgba(255, 159, 64, 0.2)');
gradient_stroke_orange.addColorStop(0.25, 'rgba(255, 159, 64, 0)');
var border_color_green = 'rgb(75, 192, 192)';
var gradient_stroke_green = ctx.createLinearGradient(0, 230, 0, 50);
gradient_stroke_green.addColorStop(1, 'rgba(75, 192, 192, 0.4)');
gradient_stroke_green.addColorStop(0.75, 'rgba(75, 192, 192, 0.3)');
gradient_stroke_green.addColorStop(0.5, 'rgba(75, 192, 192, 0.2)');
gradient_stroke_green.addColorStop(0.25, 'rgba(75, 192, 192, 0)');
var height_values = [
{% for height_weight in height_weight_list %}
{
x: '{{ height_weight.date | date:"d-m-Y" }}',
y: '{{ height_weight.weight }}'
},
{% endfor %}
]
var weight_values = [
{% for height_weight in height_weight_list %}
{
x: '{{ height_weight.date | date:"d-m-Y" }}',
y: '{{ height_weight.height | add:"-100" }}'
},
{% endfor %}
]
var bmi_value = [
{% for height_weight in height_weight_list %}
{
x: '{{ height_weight.date | date:"d-m-Y" }}',
y: '{{ height_weight.bmi }}'
},
{% endfor %}
]
var height_weight_data = {
datasets: [
{
label: 'Weight',
cubicInterpolationMode: 'monotone',
backgroundColor: gradient_stroke_pink,
borderColor: border_color_pink,
pointBackgroundColor: border_color_pink,
fill: true,
data: height_values,
hidden: true,
},
{
label: 'Height',
cubicInterpolationMode: 'monotone',
backgroundColor: gradient_stroke_orange,
borderColor: border_color_orange,
pointBackgroundColor: border_color_orange,
fill: true,
data: weight_values,
hidden: true,
},
{
label: 'BMI',
cubicInterpolationMode: 'monotone',
backgroundColor: gradient_stroke_green,
borderColor: border_color_green,
pointBackgroundColor: border_color_green,
fill: true,
data: bmi_value,
},
],
};
new Chart(ctx, {
responsive: true,
type: 'line',
data: height_weight_data,
options: {
scales: {
x: {
type: 'time',
display: true,
scaleLabel: {
display: true,
labelString: 'Date',
ticks: {
autoSkip: true,
source: 'data',
},
},
time: {
parser: timeFormat,
tooltipFormat: 'LL',
round: 'day',
},
},
},
plugins: {
legend: {
display: true,
position: 'bottom',
}
}
},
});
{% endif %}
</script>
{% endblock %}