137 lines
4 KiB
HTML
137 lines
4 KiB
HTML
{% extends "admin/base_site.html" %}
|
|
{% load admin_static %}
|
|
|
|
{% block extrastyle %}
|
|
<style>
|
|
div#period_choice { margin: 0 auto; text-align: center;}
|
|
select#section_select { width: 8em; margin-right: 2em; }
|
|
select#period_select { width: 16em; }
|
|
|
|
div#student_choice { float: left; }
|
|
select#student_select { width: 16em; }
|
|
|
|
div#corp_choice { float: right; }
|
|
select#corp_select { width: 16em; }
|
|
|
|
div#student_detail { float:left; width: 30%; margin: 1em; }
|
|
div#corp_detail { float:left; width: 30%; margin: 1em; }
|
|
|
|
div#training_form { text-align: center; }
|
|
input#valid_training { display: none; }
|
|
</style>
|
|
{% endblock %}
|
|
|
|
{% block extrahead %}
|
|
<script type="text/javascript" src="{% static "admin/js/jquery.js" %}"></script>
|
|
<script type="text/javascript">
|
|
function update_periods(section_id) {
|
|
$.getJSON('/section/' + section_id + '/periods/', function(data) {
|
|
var sel = $('#period_select');
|
|
sel.append($("<option />").val('').text('-------'));
|
|
if (data.length > 0) {
|
|
$.each(data, function() {
|
|
sel.append($("<option />").val(this[0]).text(this[1]));
|
|
})
|
|
}
|
|
update_students('');
|
|
update_corporations('');
|
|
});
|
|
}
|
|
|
|
function update_students(period_id) {
|
|
$('#student_select').find('option').remove();
|
|
$('#student_detail').html('');
|
|
current_student = null;
|
|
$('input#valid_training').hide()
|
|
if (period_id == '') return;
|
|
$.getJSON('/period/' + period_id + '/students/', function(data) {
|
|
var sel = $('#student_select');
|
|
$.each(data, function() {
|
|
sel.append($("<option />").val(this.id).text(this.name));
|
|
})
|
|
});
|
|
}
|
|
|
|
function update_corporations(period_id) {
|
|
$('#corp_select').find('option').remove();
|
|
$('#corp_detail').html('');
|
|
current_corp = null;
|
|
$('input#valid_training').hide()
|
|
if (period_id == '') return;
|
|
$.getJSON('/period/' + period_id + '/corporations/', function(data) {
|
|
var sel = $('#corp_select');
|
|
$.each(data, function() {
|
|
sel.append($("<option />").val(this[0]).text(this[1]));
|
|
})
|
|
});
|
|
}
|
|
|
|
$(document).ready(function() {
|
|
$('#section_select').change(function(ev) {
|
|
// Update period list when section is modified
|
|
$('#period_select').find('option').remove();
|
|
update_periods($(this).val());
|
|
});
|
|
|
|
$('#period_select').change(function(ev) {
|
|
// Update student/corporation list when period is modified
|
|
update_students($(this).val());
|
|
update_corporations($(this).val());
|
|
});
|
|
|
|
$('#student_select').change(function(ev) {
|
|
$('#student_detail').load('/student/' + $(this).val() + '/summary/');
|
|
current_student = $(this).val();
|
|
if (current_corp !== null) $('input#valid_training').show()
|
|
});
|
|
|
|
$('#corp_select').change(function(ev) {
|
|
$('#corp_detail').load('/corporation/' + $(this).val() + '/summary/');
|
|
current_corp = $(this).val();
|
|
if (current_student !== null) $('input#valid_training').show()
|
|
});
|
|
|
|
$('#valid_training').click(function() {
|
|
$.post('/training/new/', {period: $('#period_select').val(), student: current_student, corp: current_corp},
|
|
function(data) {
|
|
// On response: remove student from list, remove corp if no more avails
|
|
if (data == 'OK') alert("OK");
|
|
});
|
|
});
|
|
|
|
update_periods($('#section_select').val());
|
|
});
|
|
|
|
var current_student = null;
|
|
var current_corp = null;
|
|
</script>
|
|
{% endblock %}
|
|
|
|
{% block content %}
|
|
<div id="period_choice">
|
|
<form>
|
|
<label for="section_select">Filière:</label>
|
|
<select id="section_select">{% for sect in sections %}<option value="{{ sect.id }}">{{ sect.name }}</option>{% endfor %}</select>
|
|
<label for="period_select">Période:</label>
|
|
<select id="period_select"></select>
|
|
</form>
|
|
</div>
|
|
|
|
<div id="student_choice">
|
|
<form>
|
|
<select id="student_select" size="15"></select>
|
|
</form>
|
|
</div>
|
|
|
|
<div id="corp_choice">
|
|
<form>
|
|
<select id="corp_select" size="15"></select>
|
|
</form>
|
|
</div>
|
|
|
|
<div id="training_main">
|
|
<div id="student_detail"></div>
|
|
<div id="corp_detail"></div>
|
|
<div id="training_form"><input id="valid_training" type="button" value="Valider ce stage"></div>
|
|
</div>
|
|
{% endblock %}
|