ResultManager/script/contests.js
2019-08-08 16:58:29 +03:00

131 lines
4.0 KiB
JavaScript

/**
* /script/contests.js
* @version 1.0
* @desc Javascript file for the contests submenu
* @author Fándly Gergő Zoltán (fandlygergo@gmail.hu, systemtest.tk)
* @copy 2017 Fándly Gergő Zoltán
* License:
Result Manager for managing results of students in bilingual school systems.
Copyright (C) 2017 Fándly Gergő Zoltán
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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
**/
function contestsLoadList(){
$("#list").slideUp(function(){
$.ajax({
url: "./subs/loader.php",
data: {"load":"contests", "backend":true, "list":$("#schoolyear").val()},
type: "GET",
success: function(response){
$("#list").html(response);
$(".table").footable();
$("#list").slideDown();
}
});
});
}
function contestsFilterApply(){
$("#list").slideUp(function(){
$.ajax({
url: "./subs/loader.php?load=contests&backend&list="+$("#schoolyear").val(),
type: "POST",
data: $("#dd_filter_form").serialize(),
success: function(response){
$("#list").html(response);
$(".table").footable();
$("#list").slideDown();
}
});
});
}
function contestsFilterReset(){
$("#dd_filter_form")[0].reset();
contestsLoadList();
}
function contestsNew(){
$.ajax({
url: "./subs/loader.php?load=contests&backend",
type: "POST",
data: $("#dd_new_form").serialize(),
success: function(){
$("#dd_new_form")[0].reset();
loadMessages();
contestsLoadList();
}
});
}
function contestsEdit(id){
$.ajax({
url: "./subs/loader.php?load=contests&backend&getdata="+id,
type: "GET",
success: function(response){
var data=JSON.parse(response);
$("#dd_edit_form input[name=edit]").val(data.id);
$("#dd_edit_form input[name=name_1]").val(data.name_1);
$("#dd_edit_form input[name=name_2]").val(data.name_2);
$("#dd_edit_form select[name=subject] option[value="+data.subject+"]").attr("selected", true);
$("#dd_edit_form textarea[name=description]").text(data.description);
$("#dd_edit_form input[name=ministry_support][value="+data.ministry_support+"]").attr("checked", true);
$("#dd_edit_form input[name=ministry_place]").val(data.ministry_place);
$("#dd_edit").slideDown();
smoothScroll("#dd_edit");
}
});
}
function contestsSubmitEdit(){
$.ajax({
url: "./subs/loader.php?load=contests&backend",
type: "POST",
data: $("#dd_edit_form").serialize(),
success: function(){
$("#dd_edit").slideUp(function(){
$("#dd_edit_form")[0].reset();
});
loadMessages();
contestsLoadList();
}
});
}
function contestsCancelEdit(){
$("#dd_edit").slideUp(function(){
$("#dd_edit_form")[0].reset();
});
}
function contestsDelete(id, elem){
if(confirm($("#contestsDeleteConfirm").text())){
$.ajax({
url: "./subs/loader.php?load=contests&backend",
type: "POST",
data: {"delete": id},
success: function(){
loadMessages();
footableRemoveElem(elem);
}
});
}
}
/*
* RUN
*/
contestsLoadList();