Jarvis/jarvis/followup/templates/seasoninformations/create.html

156 lines
8.8 KiB
HTML
Raw Normal View History

2023-04-25 17:06:14 +02:00
{% extends "base.html" %}
{% load static %}
{% load has_group %}
{% block content %}
<div class="row justify-content-center">
<div class="col-12 col-sm-12 col-md-8 col-lg-6 col-xl-6">
<div class="card">
<div class="card-header">
<h4 class="">{% if season_information_id %}Edit{% else %}Add{% endif %} season informations</h4>
</div>
<div class="card-body">
<form
action="{% if season_information_id %}{% url 'season_information_update' season_information_id %}{% else %}{% url 'season_information_create' %}{% endif %}"
method="post" class="form-horizontal" id="formulaire" name="formulaire">
{% csrf_token %}
<div class="form-group row ">
<label for="id_date" class="col-sm-3 col-md-3 col-lg-3 col-xl-3 col-form-label">Gymnast
<span class="text-danger"><b>*</b></span></label>
<div
class="col-sm-9 col-md-9 col-lg-6 {% if form.jumper.errors %}has-danger{% endif %}">
{{ form.gymnast }}
{{ form.gymnast_related }}
{% if form.gymnast.errors %}&nbsp;<span class="btn btn-sm btn-danger-outline">{% for error in form.gymnast.errors %}{{ error }}{% endfor %}</span>{% endif %}
</div>
</div>
<div class="form-group row ">
<label for="id_season" class="col-sm-3 col-md-3 col-lg-3 col-xl-3 col-form-label">Season <span class="text-danger"><b>*</b></span></label>
<div
class="col-sm-3 col-md-4 col-lg-4 col-xl-3 {% if form.season.errors %}has-danger{% endif %}">
{{ form.season }}
{% if form.season.errors %}<span class="btn btn-sm btn-danger-outline">{% for error in form.season.errors %}{{ error }}{% endfor %}</span>{% endif %}
</div>
</div>
<div class="form-group row ">
<label for="id_club" class="col-4 col-sm-3 col-form-label">Club <span class="text-danger"><b>*</b></span></label>
<div class="col-8 col-md-9 col-lg-6 {% if form.club.errors %}has-danger{% endif %}">
{{ form.club }}
{{ form.club_related }}
{% if form.club.errors %}&nbsp;<span class="btn btn-sm btn-danger-outline">{% for error in form.club.errors %}{{error}}{% endfor %}</span>{% endif %}
</div>
</div>
<div class="form-group row ">
<label for="id_number_of_training_sessions_per_week" class="col-sm-3 col-md-3 col-lg-3 col-xl-3 col-form-label">Training/week <span class="text-danger"><b>*</b></span></label>
<div class="col-sm-3 col-md-3 col-lg-2 {% if form.number_of_training_sessions_per_week.errors %}has-danger{% endif %}">
{{ form.number_of_training_sessions_per_week }}
{% if form.number_of_training_sessions_per_week.errors %}&nbsp;<span class="btn btn-sm btn-danger-outline">{% for error in form.number_of_training_sessions_per_week.errors %}{{ error }}{% endfor %}</span>{% endif %}
</div>
</div>
<div class="form-group row ">
<label for="id_number_of_hours_per_week" class="col-sm-3 col-md-3 col-lg-3 col-xl-3 col-form-label">Hours/week <span class="text-danger"><b>*</b></span></label>
<div class="col-sm-3 col-md-3 col-lg-2 {% if form.number_of_hours_per_week.errors %}has-danger{% endif %}">
{{ form.number_of_hours_per_week }}
{% if form.number_of_hours_per_week.errors %}&nbsp;<span class="btn btn-sm btn-danger-outline">{% for error in form.number_of_hours_per_week.errors %}{{ error }}{% endfor %}</span>{% endif %}
</div>
</div>
<div class="form-group row ">
<label for="id_number_of_s_and_c_sessions_per_week" class="col-sm-3 col-md-3 col-lg-3 col-xl-3 col-form-label">S&C Training/week</label>
<div class="col-sm-3 col-md-3 col-lg-2 {% if form.number_of_s_and_c_sessions_per_week.errors %}has-danger{% endif %}">
{{ form.number_of_s_and_c_sessions_per_week }}
{% if form.number_of_s_and_c_sessions_per_week.errors %}&nbsp;<span class="btn btn-sm btn-danger-outline">{% for error in form.number_of_s_and_c_sessions_per_week.errors %}{{ error }}{% endfor %}</span>{% endif %}
</div>
</div>
<div class="form-group row ">
<label for="id_number_of_s_and_c_hours_per_week" class="col-sm-3 col-md-3 col-lg-3 col-xl-3 col-form-label">S&C Hours/week</label>
<div class="col-sm-3 col-md-3 col-lg-2 {% if form.numbernumber_of_s_and_c_hours_per_week_of_hours_per_week.errors %}has-danger{% endif %}">
{{ form.number_of_s_and_c_hours_per_week }}
{% if form.number_of_s_and_c_hours_per_week.errors %}&nbsp;<span class="btn btn-sm btn-danger-outline">{% for error in form.number_of_s_and_c_hours_per_week.errors %}{{ error }}{% endfor %}</span>{% endif %}
</div>
</div>
<div class="form-group row ">
<label for="id_category" class="col-sm-3 col-md-3 col-lg-3 col-xl-3 col-form-label">Category <span class="text-danger"><b>*</b></span></label>
<div class="col-sm-3 col-md-3 col-lg-3 {% if form.category.errors %}has-danger{% endif %}">
{{ form.category }}
{% if form.category.errors %}&nbsp;<span class="btn btn-sm btn-danger-outline">{% for error in form.category.errors %}{{ error }}{% endfor %}</span>{% endif %}
</div>
</div>
<div class="form-group text-center">
<input type="submit" value="{% if note_id %}Save{% else %}Add{% endif %}"
class="btn btn-warning" />
</div>
</form>
</div>
</div>
</div>
</div>
{% endblock %}
{% block footerscript %}
<script type="text/javascript">
$(function () {
blackDashboard.initDateTimePicker();
});
const csrf_token = "{{ csrf_token|escapejs }}";
const gymnast_lookup = "{% url 'gymnast_lookup' %}";
const club_lookup = "{% url 'club_lookup' %}";
$('#id_season').keyup(function(){
if($(this).val().length == 4 && $(this).val().indexOf(',') == -1) {
var value = parseInt($(this).val());
var res = value.toString() + '-' + (value + 1).toString();
$(this).val(res);
}
});
$('#id_club_related').autocomplete({
source: function(request, response) {
$.ajax({
url: club_lookup,
method: "POST",
data: {
pattern: $('#id_club_related').val(),
csrfmiddlewaretoken: csrf_token
},
dataType: "json",
success: function(data) {
if(data.length != 0) {
response($.map(data, function(item) {
return {
label: item.Name,
value: item.Name,
clubid: item.ID
}
}))
} else {
response([{ label: 'No result found.', value: '' }]);
};
},
error: function (exception) {
console.log(exception);
}
});
},
minLength: 3,
select: function (event, ui) {
$($(this).data('ref')).val(ui.item.clubid);
},
{% if request.session.template == 0 %}
classes: {
"ui-widget-content": "custom_autocomplete_ul",
"ui-autocomplete": "custom_autocomplete_ul",
"ui-menu-item-wrapper": "custom_autocomplete_li",
"ui-menu-item": "custom_autocomplete_li",
},
{% endif %}
});
</script>
{% if request.session.template == 0 %}
<script src="{% static "js/template_users/gymnast_autocomplete_black.js" %}"></script>
{% else %}
<script src="{% static "js/template_users/gymnast_autocomplete.js" %}"></script>
{% endif %}
{% endblock %}