/** * /script/register.js * @version 1.4 * @desc Register javascript file * @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 . **/ function registerLoadList(){ $("#list").slideUp(function(){ $.ajax({ url: "./subs/loader.php", data: {"load":"register", "backend":true, "list":$("#schoolyear").val()}, type: "GET", success: function(response){ $("#list").html(response); $(".table").footable(); $("#list").slideDown(); } }); }); } function registerFilterApply(){ $("#list").slideUp(function(){ $.ajax({ url: "./subs/loader.php?load=register&backend&list", type: "POST", data: $("#dd_filter_form").serialize(), success: function(response){ $("#list").html(response); $(".table").footable(); $("#list").slideDown(); } }); }); } function registerFilterReset(){ $("#dd_filter_form")[0].reset(); registerLoadList(); } function registerEdit(id){ $.ajax({ url: "./subs/loader.php?load=register&backend&getdata="+id, type: "GET", success: function(response){ var data=JSON.parse(response); $("#dd_edit_form input[name=edit]").val(id); $("#dd_edit_form input[name=student][value="+data.student+"]").attr("checked", true); $("#dd_edit_form input[name=contest][value="+data.contest+"]").attr("checked", true); $("#dd_edit_form input[name=phase][value="+data.phase+"]").attr("checked", true); $("#dd_edit_form input[name=teacher][value="+data.teacher+"]").attr("checked", true); $("#dd_edit_form input[name=place][value="+(data.place<0?data.place:0)+"]").attr("checked", true); if(data.place>0){ $("#dd_edit_form input[name=place_c]").val(data.place); $("#registerCustomPlaceEdit").slideDown(); } $("#dd_edit_form input[name=place_c]").attr("required", data.place>0); $("#dd_edit_form textarea[name=mention]").text(data.mention); $("#dd_edit").slideDown(); smoothScroll("#dd_edit"); } }); } function registerSubmitEdit(){ $.ajax({ url: "./subs/loader.php?load=register&backend", type: "POST", data: $("#dd_edit_form").serialize(), success: function(){ $("#dd_edit").slideUp(function(){ $("#dd_edit_form")[0].reset(); }); loadMessages(); registerLoadList(); } }); } function registerCancelEdit(){ $("#dd_edit").slideUp(function(){ $("#dd_edit_form")[0].reset(); }); } function registerDelete(id, elem){ if(confirm($("#registerDeleteConfirm").text())){ $.ajax({ url: "./subs/loader.php?load=register&backend", type: "POST", data: {"delete": id}, success: function(){ loadMessages(); footableRemoveElem(elem); } }); } } function registerNew(){ $.ajax({ url: "./subs/loader.php?load=register&backend", type: "POST", data: $("#dd_new_form").serialize(), success: function(response){ var data=JSON.parse(response); $("#newSubmitPrevContent tbody").html(data.prev); $("#dd_newSubmit_form input[name=newSubmit]").val(JSON.stringify(data.params)); $("#newSubmitPrevContent").footable(); $("#dd_new_form")[0].reset(); $("#dd_newSubmit").slideDown(); smoothScroll("#dd_newSubmit"); } }); } function registerNewSubmit(){ $.ajax({ url: "./subs/loader.php?load=register&backend", type: "POST", data: $("#dd_newSubmit_form").serialize(), success: function(){ $("#dd_newSubmit").slideUp(function(){ $("#dd_newSubmit_form")[0].reset(); $("#newSubmitPrevContent tbody").html(""); loadMessages(); registerLoadList(); }); } }); } function registerNewCancel(){ $("#dd_newSubmit").slideUp(function(){ $("#dd_newSubmit_form")[0].reset(); $("#newSubmitPrevContent tbody").html(""); }); } function registerExport(){ $.ajax({ url: "./subs/loader.php?load=register&backend", type: "POST", data: $("#dd_export_form").serialize(), beforeSend: function(){ $("#export_progress").css("display", "block"); }, success: function(response){ $("#download_file").val(response); $("#export_progress").css("display", "none"); $("#export_ready").css("display", "block"); } }); } function registerExportDownload(){ $("#export_ready").css("display", "none"); window.location="./subs/loader.php?load=register&backend&expdownload="+$("#download_file").val(); loadMessages(); } /* * RUN */ registerLoadList(); $("#dd_new_form input[name=place]").click(function(){ toggleRequiredFormElement("#registerCustomPlaceNew", $("#dd_new_form input[name=place][value=0]").is(":checked")); }); $("#dd_edit_form input[name=place]").click(function(){ toggleRequiredFormElement("#registerCustomPlaceEdit", $("#dd_edit_form input[name=place][value=0]").is(":checked")); });