allerta-vvf/server/templates/edit_training.html

144 lines
5.9 KiB
HTML
Raw Normal View History

2021-04-26 15:33:44 +02:00
{% extends "base.html" %}
{% block menu %}
{% endblock %}
{% block content %}
2020-11-14 23:00:36 +01:00
{% if training.modalità == "edit" or training.modalità == "add" %}
<form method="post">
<div class="container">
2021-04-26 15:33:44 +02:00
<div class="form-group">
<label for="date-picker">{{ 'Training day'|t }}</label>
<input id="date-picker" aria-label="Date picker" placeholder="DD/MM/YYY" autocomplete="off" name="date" data-provide="datepicker"
2020-11-25 11:29:19 +01:00
value="{{ values.date }}" type="text" class="form-control">
2020-10-19 23:34:49 +02:00
</div>
2021-04-26 15:33:44 +02:00
<div class="form-group">
<label for="name">{{ 'Name'|t }}</label>
<input id="name" class="form-control" type="text" name="name" placeholder="1° training" required value="{{ values.name }}">
</div>
<div class="form-group">
<label for="timePicker1">{{ 'Start time'|t }}</label>
<input id="timePicker1" class="form-control" type="time" name="start_time" required value="{{ values.beginning }}">
</div>
<div class="form-group">
<label for="timePicker2">{{ 'End time'|t }}</label>
<input id="timePicker2" class="form-control" type="time" name="end_time" required value="{{ values.end }}">
</div>
<div class="form-group">
<label>{{ 'Chief'|t }}</label>
<br>
{% for user in training.crew %}
{% if not user.hidden %}
<div class="form-check">
<input aria-label="{{ username(user.id) }}" id="chief-{{ user.id }}" class="form-check-input chief chief-{{ user.id }}"
style="transform: scale(1.4); -webkit-transform: scale(1.4);" type="checkbox" name='chief[]'
value='{{ user.id }}'>
<label class="form-check-label" for="chief-{{ user.id }}">
{{ username(user.id) }}
</label>
</div>
{% endif %}
{% endfor %}
2020-11-14 23:00:36 +01:00
</div>
2021-05-16 21:32:43 +02:00
<script nonce="{{ nonce }}">
2020-11-25 11:29:19 +01:00
$('.chief').on('change', function () {
2020-11-14 23:00:36 +01:00
$('input[name="' + this.name + '"]').not(this).prop('checked', false);
});
</script>
2021-04-26 15:33:44 +02:00
<div class="form-group">
<label>{{ 'Crew'|t }}</label>
<br>
{% for user in training.crew %}
{% if not user.hidden %}
<div class="form-check">
<input aria-label="{{ username(user.id) }}" id="crew-{{ user.id }}" class="form-check-input crew crew-{{ user.id }}"
style="transform: scale(1.4); -webkit-transform: scale(1.4);" type="checkbox" name='crew[]'
value='{{ user.id }}'>
<label class="form-check-label" for="crew-{{ user.id }}">
{{ username(user.id) }}
</label>
</div>
{% endif %}
{% endfor %}
2020-11-14 23:00:36 +01:00
</div>
2021-03-23 19:52:44 +01:00
{% if option('use_location_picker') %}
2021-04-26 15:33:44 +02:00
<label>{{ 'Training place'|t }}</label>
2021-03-23 19:52:44 +01:00
<div id="map"></div>
<div id="search">
2021-04-26 15:33:44 +02:00
<div class="form-inline">
<div class="form-group mx-sm-3 mb-2">
<input type="text" class="form-control" name="addr" value="" id="addr" size="50" />
</div>
<div class="form-group mx-sm-3 mb-2">
2021-05-27 23:47:47 +02:00
<button id="search_button" type="button" class="btn btn-primary mb-2">
{{ 'Search'|t }}
</button>
<script nonce="{{ nonce }}">
2021-05-28 15:23:57 +02:00
$("#search_button").click(function(){
2021-05-27 23:47:47 +02:00
allertaJS.maps.addrSearch('{{ 'Search results'|t }}', '{{ 'No results found'|t }}');
});
</script>
2021-04-26 15:33:44 +02:00
</div>
</div>
2021-03-23 19:52:44 +01:00
<div id="results"></div>
</div>
<input type="hidden" name="place" value="" />
2021-05-27 23:47:47 +02:00
<script nonce="{{ nonce }}">window.loadMapOnScriptLoad = true;</script>
{{ script('maps.js') }}
2021-03-23 19:52:44 +01:00
{% else %}
2021-05-01 12:18:50 +02:00
<div class="form-group">
2021-04-26 15:33:44 +02:00
<label for="place">{{ 'Training place'|t }}</label>
<input id="place" type="text" class="form-control" name="place" required value="{{ values.place }}">
</div>
2021-05-01 12:18:50 +02:00
<br>
2021-03-23 19:52:44 +01:00
{% endif %}
2021-05-01 12:18:50 +02:00
<div class="form-group">
2021-04-26 15:33:44 +02:00
<label for="notes">{{ 'Others notes (ex. others infos)'|t }}</label><br>
<textarea class="form-control" id="notes" name='notes'></textarea>
</div>
2020-11-14 23:00:36 +01:00
<br>
<input id="modalità" type="hidden" value="{{ training.modalità }}" name="mod"></input>
<input id="id" type="hidden" value="{{ training.id }}" name="id"></input>
<input id="token" type="hidden" value="{{ training.token }}" name="token"></input>
2021-04-26 18:32:21 +02:00
<button id="submit_button" type="submit" class="btn btn-primary">{{ 'Submit'|t }}</button>
2020-10-19 23:34:49 +02:00
</div>
2020-11-14 23:00:36 +01:00
</form>
2021-05-16 21:32:43 +02:00
<script nonce="{{ nonce }}">
2020-11-14 23:00:36 +01:00
{% if training.modalità == "edit" %}
2021-05-04 16:22:28 +02:00
{% if option('use_location_picker') %}
{% set place = values.place|split('#')[0] %}
2021-05-28 23:45:48 +02:00
$(function(){
allertaJS.maps.setMarker(new L.LatLng({{place|split(';')[0]}}, {{place|split(';')[1]}}), true);
});
2021-05-04 16:22:28 +02:00
{% endif %}
2020-11-25 11:29:19 +01:00
$.each('{{ values.chief|striptags|e("js") }}'.split(','), function (index, value) {
$('.chief-' + value).prop('checked', true);
2020-07-01 21:00:53 +02:00
});
2020-11-25 11:29:19 +01:00
$.each('{{ values.crew|striptags|e("js") }}'.split(','), function (index, value) {
$('.crew-' + value).prop('checked', true);
2020-11-14 23:00:36 +01:00
});
2020-11-25 11:29:19 +01:00
$('#notes').val('{{ values.notes|e("js") }}');
2020-11-14 23:00:36 +01:00
{% endif %}
</script>
{% endif %}
{% if training.modalità == "delete" %}
<div style="margin: 0 auto; text-align: center">
<p>{{ 'Are you sure you want to delete the training?'|t }}</p>
<form method="post">
<input id="modalità" type="hidden" value="delete" name="mod"></input>
<input id="token" type="hidden" value="{{ training.token }}" name="token"></input>
<input id="id" type="hidden" value="{{ training.id }}" name="id"></input>
2021-03-23 19:52:44 +01:00
<button id="remove" type="submit">{{ 'Submit'|t }}</button>
2020-11-14 23:00:36 +01:00
</form>
2021-05-16 21:32:43 +02:00
<script nonce="{{ nonce }}">
2020-11-14 23:00:36 +01:00
$('form').submit(function () {
return confirm("{{ 'The action cannot be canceled. Are you sure you want to continue?'|t }}");
});
2020-07-01 21:00:53 +02:00
</script>
</div>
2020-11-14 23:00:36 +01:00
{% endif %}
2021-04-26 15:33:44 +02:00
{% block footer %}
{% endblock %}
{% endblock %}