templates/manager_dissertations_wait_commission_list.html
{% extends "layout.html" %}
{% load static %}
{% load i18n %}
{% comment "License" %}
* OSIS stands for Open Student Information System. It's an application
* designed to manage the core business of higher education institutions,
* such as universities, faculties, institutes and professional schools.
* The core business involves the administration of students, teachers,
* courses, programs and so on.
*
* Copyright (C) 2015-2019 Université catholique de Louvain (http://www.uclouvain.be)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* A copy of this license - GNU General Public License - is available
* at the root of the source code of this program. If not,
* see http://www.gnu.org/licenses/.
{% endcomment %}
{% block style %}
<link rel="stylesheet" href="{% static 'css/dataTables.bootstrap.min.css' %}">
<link rel="stylesheet" href="{% static 'css/jquery-ui.css' %}">
<link rel="stylesheet" href="{% static 'css/dissertation_style.css' %}">
{% endblock %}
{% block breadcrumb %}
<li><a href="{% url 'studies' %}" id="lnk_studies">{% trans "Students' path" %}</a></li>
<li id="lnk_cohorts_management"><a href="{% url 'cohorts_management' %}">{% trans "Cohorts management" %}</a></li>
<li><a href="{% url 'dissertations' %}" id="lnk_dissertations">{% trans 'Dissertations' %}</a></li>
<li class="active">{% trans 'Dissertations' %}</li>
{% endblock %}
{% block content %}
<div class="page-header">
<h2>{% trans 'Dissertations' %}</h2>
</div>
<ul class="nav nav-tabs">
<li><a href="{% url 'manager_dissertations_list' %}">{% trans 'All dissertations' %}</a></li>
<li><a href="manager_dissertations_wait_list">{% trans 'Waiting promotor' %}</a></li>
{% if show_validation_commission %}
<li class="active"><a href="{% url 'manager_dissertations_wait_comm_list' %}">{% trans 'Waiting commission' %}</a></li>
{% endif %}
{% if show_evaluation_first_year %}
<li><a href="{% url 'manager_dissertations_wait_eval_list' %}">{% trans 'Waiting 1st year evaluation' %}</a></li>
{% endif %}
<li><a href="{% url 'manager_dissertations_wait_recep_list' %}">{% trans 'Waiting reception' %}</a></li>
</ul>
<div class="panel panel-default">
<br>
<table class="table table-hover" id="tb_memoire" cellpadding="10" cellspacing="5">
<thead>
<tr>
<th></th>
<th>{% trans 'Title' context 'dissertation' %}</th>
<th>{% trans 'Author'%}</th>
<th>{% trans 'Status' context 'dissertation' %}</th>
<th>{% trans 'year beginning'%}</th>
<th>{% trans 'Program'%}</th>
<th>{% trans 'Dissertation subject'%}</th>
<th>{% trans 'Action'%}</th>
</tr>
</thead>
</table>
</div>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h2 class="modal-title" id="myModalLabel"> {% trans 'Add jury member' %}</h2>
</div>
<div class="modal-body">
<form method="post" >
{% csrf_token %}
<input type="hidden" id="pk_dissertation" name="pk_dissertation" value="">
<label for="txt_status">{% trans 'Status' context 'dissertation' %}</label>
<select id="txt_status" name="status_choice" class="form-control" required>
<option value=""></option>
{% for choice in STATUS_CHOICES %}
<option value="{{choice.0}}"> {% trans choice.0 %}</option>
{% endfor %}
</select>
<label for="search_advisers">{% trans 'Teacher' %}</label>
<input id="search_advisers" name="search_advisers" class="form-control" value="">
<input type="hidden" name="adviser_pk" id="adviser_pk" value="">
<div>
{% trans 'If the concerned teacher is not in the list, you can' %}
<a href="{% url 'manager_informations_add' %}" id="lnk_informations_add" class=""
title="{% trans 'Informations'%}" target="_blank" >{% trans 'Add teacher' %}</a>
</div>
<br>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">{% trans 'close'%}</button>
<button type="button" class="btn btn-primary submit_form">{% trans 'Save'%}</button>
</div>
</form>
</div>
</div>
</div>
</div>
{% endblock %}
{% block script %}
<script type="text/javascript" src="{% static 'js/jquery.dataTables.min.js' %}"></script>
<script type="text/javascript" src="{% static 'js/dataTables.bootstrap.min.js' %}"></script>
<script type="text/javascript" src="{% static 'js/jquery-ui.js' %}"></script>
<script>
function format_row_child(list_dissert_roles,dissert)
{
var pk ='';
var bt_add = '';
var tab_dissert_roles ='<tr>';
tab_dissert_roles +='<td> {% trans 'Dissertation jury'%}: </td>';
for(var i =0;i < list_dissert_roles.length;i++)
{
var item = list_dissert_roles[i];
tab_dissert_roles +='<tr>';
tab_dissert_roles +='<td> </td>';
tab_dissert_roles +='<td> </td>';
tab_dissert_roles +='<td> '+item.status+' </td>';
tab_dissert_roles +='<td> '+item.first_name+' </td>';
tab_dissert_roles +='<td> '+item.last_name+' </td>';
tab_dissert_roles +='<td> </td>';
tab_dissert_roles +='<td> '+
'<a href="#" class="btn btn-warning bt_warning_'+dissert.pk+'"'+
'id="dissert_roles_'+item.pk+'" role="button">'+
'<span class="glyphicon glyphicon-remove span2"></span></a> </td>';
tab_dissert_roles =tab_dissert_roles+'<tr>';
};
if (list_dissert_roles.length < 4){
bt_add='<a href="#"lnk_add_dissertation_jury_member" class="add_jury btn btn-default btn-sm"'+
'role="button" title="{% trans 'Add a jury member'%}" data-toggle="modal" data-target="#myModal"'+
'data-id="'+dissert.pk+'">'+
'<span class="glyphicon glyphicon-plus" aria-hidden="true" >'+
'</span>'+
'{% trans 'Add a jury member'%}</a>';
}else
{
bt_add='';
};
return '<table cellpadding="10" cellspacing="5" border="0" style="padding-left:50px;" >'+
'<tr>'+
'<td> {% trans 'Description'%}:</td>'+'<td> </td>'+
'<td> </td>'+
'<td colspan=6>'+dissert.description+'</td>'+
'<td>'+bt_add+'</td>'+
'</tr>'+
tab_dissert_roles+
'<tr> <td><a id="reset_bt_'+dissert.pk+'" role="button" class="glyphicon glyphicon-refresh" ></a>'+
'</td></tr>'+
'</table>';
};
function get_dissertation_roles(row,rowdata)
{
$.ajax({
url:"/dissertation/manager_dissertation_role_list_json/"+rowdata.pk,
type: 'get',
success: function (dissertation_roles_json) {
row.child(format_row_child(dissertation_roles_json,rowdata)).show();
},
error: function (response) {
alert("Error :"+ response.error +" with response dissertation_role_list...' %}");
}
})
};
$(document).ready(function()
{
$.ajax(
{
url:"/dissertation/manager_dissertations_wait_comm_json_list",
error: function (response){
alert("Error :"+ response.error +" with manager_dissertations_wait_comm_json_list ");
},
}).done(function(dissertations_json)
{
var table_dissertations=$('#tb_memoire').DataTable(
{
data:dissertations_json,
rowId: 'pk',
error: function (response){
alert("Error :"+ response.error );
},
"columns":
[{
"className":'details-control',
"orderable":false,
"data":null,
render: function ( data, type, full, meta ){
htmlRendered = '<a id="glyf_'+full.pk+'" role="button" class="glyphicon glyphicon-expand"></a>';
return htmlRendered;
}
},
{
"data":"title",
render: function ( data, type, full, meta ){
htmlRendered = '<a href="/dissertation/manager_dissertations_detail/'+full.pk+' ">'+full.title+'</a>';
return htmlRendered;
}
},
{"data":"author"},
{"data":"status"},
{"data":"education_group_year"},
{"data":"education_groups"},
{"data":"proposition_dissertation"},
{
"orderable":false,
"data":'pk',
render: function ( data, type, full, meta ) {
htmlRendered = '<b><a href="/dissertation/manager_dissertations_accept_comm_list/' +
full.pk + '" class="btn btn-default" title="{% trans 'Commission accepts'%}">'+
'{% trans 'Commission accepts'%}</a></b>';
return htmlRendered;
}
}],
"order" : [[1,'asc']],
"info" : false,
"searching" : true,
"stateSave": true,
"language":
{
"sProcessing": "{% trans 'Processing...'%}",
"sSearch": "{% trans 'Search:'%}",
"sLengthMenu": "{% trans 'Show _MENU_ entries'%}",
"sInfo": "{% trans 'Showing _START_ to _END_ of _TOTAL_ entries'%}",
"sInfoEmpty": "{% trans 'Showing 0 to 0 of 0 entries'%}",
"sInfoFiltered": "{% trans '(filtered from _MAX_ total entries)'%}",
"sInfoPostFix": "{% trans 'datatable_infopostfix'%}",
"sLoadingRecords": "{% trans 'Loading...'%}",
"sZeroRecords": "{% trans 'No matching records found'%}",
"sEmptyTable": "{% trans 'No data available in table'%}",
"oPaginate":
{
"sFirst": "{% trans 'First'%}",
"sPrevious": "{% trans 'Previous'%}",
"sNext": "{% trans 'Next'%}",
"sLast": "{% trans 'Last'%}"
},
"oAria": {
"sSortAscending": "{% trans ': activate to sort column ascending'%}",
"sSortDescending": "{% trans ': activate to sort column descending'%}",
}
},
});
$('#tb_memoire tbody').on('click', 'td.details-control', function()
{
var tr = $(this).closest('tr');
var row = table_dissertations.row(tr);
if(row.child.isShown())
{
row.child.hide();
tr.removeClass('shown');
$('#glyf_'+row.data().pk).find('i').toggleClass('glyphicon-arrow-right').toggleClass('glyphicon-arrow-left');
}
else
{
get_dissertation_roles(row,row.data());
tr.addClass('shown');
}
});
});
});
$(document).on('click', '.glyphicon-refresh', function (event) {
var bt_reset_id=event.target.id;
bt_reset_id= bt_reset_id.replace(/reset_bt_/, "");
var table_dissertations=$('#tb_memoire').DataTable();
var row_parent = table_dissertations.row('#'+bt_reset_id);
get_dissertation_roles(row_parent,row_parent.data());
});
$(document).on('click', '.add_jury', function (event){
var id_dissertation = $(this).data("id");
$('#pk_dissertation').attr('value',id_dissertation);
$( "#adviser_pk" ).val("");
$( "#search_advisers" ).val("");
});
$(document).on('click', '.submit_form', function (event){
var status_choice = $(this).closest("form").find("select[name='status_choice']").val();
var adviser = $(this).closest("form").find("input[name='adviser_pk']").val();
var dissertation = $(this).closest("form").find("input[name='pk_dissertation']").val();
$.ajax({
url: '{% url 'manager_dissertations_jury_new_ajax' %}',
type: 'POST',
data: jQuery.param({ status_choice: status_choice , adviser_pk : adviser, pk_dissertation : dissertation}) ,
contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
success: function (response) {
var table_dissertations=$('#tb_memoire').DataTable();
var row_parent = table_dissertations.row('#'+dissertation);
get_dissertation_roles(row_parent,row_parent.data());
},
error: function (response) {
if (response.status == 400){
alert("{% trans 'Error' %} "+response.status +" {% trans 'Maximum number of members of the jury reached' %}");
get_dissertation_roles(row_parent,row_parent.data());
}else
{
alert("{% trans 'Error' %} "+response.status +" {% trans 'The status or the teacher are missing' %}");
}
}
});
$( "#adviser_pk" ).val("");
$( "#search_advisers" ).val("");
});
$(document).on('click', '.btn-warning', function (event) {
var confirmation=confirm('{% trans 'You are ready to delete this jury member. Are you sure you want to continue?'%}');
if (confirmation==true)
{
var bt_delete_dissert_role_id=$(this).attr('id');
bt_delete_dissert_role_id=bt_delete_dissert_role_id.replace(/dissert_roles_/,"");
$.ajax({
url:"/dissertation/manager_dissertations_role_delete_by_ajax/"+bt_delete_dissert_role_id,
error: function (response) {
alert("Error :"+ response.status +"response dissertation role delete {% trans 'No result' %}");
}
});
var id_dissert_to_refresh=$(this).attr('class').split(' ');
id_dissert_to_refresh= id_dissert_to_refresh[2].replace(/bt_warning_/,"");
var table_dissertations=$('#tb_memoire').DataTable();
var row_parent = table_dissertations.row('#'+id_dissert_to_refresh);
setTimeout(function() { get_dissertation_roles(row_parent,row_parent.data()) }, 1000);
}
});
$(function(){
$("#search_advisers").autocomplete({
source: {{all_advisers_array | safe}},
minLength: 3,
delay: 100,
error: function (response) {
alert("Error :"+ response.status +" find_adviser_list {% trans 'No result' %}");
},
focus: function( event, ui ) {
$( "#adviser_pk" ).val( ui.item.last_name + ' (' + ui.item.value + ')' );
return false;
},
select: function(event, ui) {
var adviser_id = ui.item.id;
$( "#adviser_pk" ).val(adviser_id);
$( "#search_advisers" ).val( ui.item.value);
return false;
}
}
)});
</script>
{% endblock %}