ResultManager/subs/part/contests.php
2019-08-08 16:58:29 +03:00

219 lines
11 KiB
PHP

<?php
/**
* /subs/contests.php
* @version 1.0
* @desc Contests menu
* @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/>.
**/
$oid=0;
?>
<div class="selfcenter">
<!-- language for jquery -->
<span id="contestsDeleteConfirm" style="display: none"><?php echo $lang['delete_confirm'] ?></span>
<!-- filter -->
<div class="dropdown selfcenter" style="width: 95%" id="dd_filter">
<div class="dropdown header">
<a onclick="toggleDropdown('#dd_filter_content', '#dd_filter_img')">
<img class="icon" src="./res/plus.png" alt="plusminus" id="dd_filter_img">
<span><?php echo $lang['filter'] ?></span>
</a>
</div>
<div class="dropdown content" id="dd_filter_content">
<form method="POST" class="ajaxform" id="dd_filter_form" onsubmit="contestsFilterApply()">
<input type="hidden" name="filter">
<p><?php echo $lang['search'].":" ?></p>
<input type="text" name="f_search" placeholder="<?php echo $lang['search']."..." ?>">
<hr>
<p><?php echo $lang['subject'].":" ?></p>
<?php
$sql=$db->prepare("SELECT id, name_1, name_2 FROM subjects ORDER BY name_1 ASC, name_2 ASC");
$sql->execute();
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
echo "<input type=\"checkbox\" name=\"f_subject[]\" id=\"o_".$oid."\" value=\"".$row['id']."\">";
echo "<label for=\"o_".$oid."\">".$row['name_1']." / ".$row['name_2']."</label>";
echo "<br>";
$oid++;
}
?>
<hr>
<p><?php echo $lang['ministry_support'].":" ?></p>
<?php
for($i=0; $i<3; $i++){
echo "<input type=\"checkbox\" name=\"f_ministry[]\" id=\"o_".$oid."\" value=\"".$i."\">";
echo "<label for=\"o_".$oid."\">".$lang['ministry_'.$i]."</label>";
echo "<br>";
$oid++;
}
?>
<hr>
<button type="submit" form="dd_filter_form"><?php echo $lang['apply'] ?></button>
<button type="button" onclick="contestsFilterReset()"><?php echo $lang['reset'] ?></button>
</form>
</div>
</div>
<hr class="placeholder">
<!-- new -->
<div class="dropdown selfcenter" style="width: 95%" id="dd_new">
<div class="dropdown header">
<a onclick="toggleDropdown('#dd_new_content', '#dd_new_img')">
<img class="icon" src="./res/plus.png" alt="plusminus" id="dd_new_img">
<span><?php echo $lang['new'] ?></span>
</a>
</div>
<div class="dropdown content" id="dd_new_content">
<form method="POST" class="ajaxform" id="dd_new_form" onsubmit="contestsNew()">
<input type="hidden" name="new">
<table>
<tr>
<td><?php echo $lang['name_1'].": " ?></td>
<td><input type="text" name="name_1" placeholder="<?php echo $lang['name_1']."..." ?>" required></td>
</tr>
<tr>
<td><?php echo $lang['name_2'].": " ?></td>
<td><input type="text" name="name_2" placeholder="<?php echo $lang['name_2']."..." ?>" required></td>
</tr>
<tr>
<td><?php echo $lang['subject'].": " ?></td>
<td>
<select name="subject" required>
<option value="-1" selected disabled><?php echo $lang['nothing'] ?></option>
<?php
$sql=$db->prepare("SELECT id, name_1, name_2 FROM subjects ORDER BY name_1 ASC, name_2 ASC");
$sql->execute();
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
echo "<option value=\"".$row['id']."\">".$row['name_1']." / ".$row['name_2']."</option>";
}
?>
</select>
</td>
</tr>
<tr>
<td><?php echo $lang['description'].": " ?></td>
<td><textarea name="description" placeholder="<?php echo $lang['description']."..." ?>" cols=50 rows=5></textarea></td>
</tr>
<tr>
<td><?php echo $lang['ministry_support'].": "?></td>
<td>
<?php
for($i=0; $i<3; $i++){
echo "<input type=\"radio\" name=\"ministry_support\" id=\"o_".$oid."\" value=\"".$i."\" required>";
echo "<label for=\"o_".$oid."\">".$lang['ministry_'.$i]."</label>";
echo "<br>";
$oid++;
}
?>
</td>
</tr>
<tr>
<td><?php echo $lang['ministry_place'].": " ?></td>
<td><input type="number" name="ministry_place" placeholder="<?php echo $lang['ministry_place']."..." ?>" min=0></td>
</tr>
</table>
<br>
<br>
<button type="submit" form="dd_new_form"><?php echo $lang['ok'] ?></button>
<button type="reset" form="dd_new_form" onclick="toggleDropdown('#dd_new_content', '#dd_new_img')"><?php echo $lang['cancel'] ?></button>
</form>
</div>
</div>
<hr class="placeholder">
<!-- edit -->
<div class="dropdown selfcenter" style="width: 95%; display: none" id="dd_edit">
<div class="dropdown header">
<span><?php echo $lang['edit'] ?></span>
</div>
<div class="dropdown content" style="display: block">
<form method="POST" class="ajaxform" id="dd_edit_form" onsubmit="contestsSubmitEdit()">
<input type="hidden" name="edit">
<table>
<tr>
<td><?php echo $lang['name_1'].": " ?></td>
<td><input type="text" name="name_1" placeholder="<?php echo $lang['name_1']."..." ?>" required></td>
</tr>
<tr>
<td><?php echo $lang['name_2'].": " ?></td>
<td><input type="text" name="name_2" placeholder="<?php echo $lang['name_2']."..." ?>" required></td>
</tr>
<tr>
<td><?php echo $lang['subject'].": " ?></td>
<td>
<select name="subject" required>
<option value="-1" selected disabled><?php echo $lang['nothing'] ?></option>
<?php
$sql=$db->prepare("SELECT id, name_1, name_2 FROM subjects ORDER BY name_1 ASC, name_2 ASC");
$sql->execute();
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
echo "<option value=\"".$row['id']."\">".$row['name_1']." / ".$row['name_2']."</option>";
}
?>
</select>
</td>
</tr>
<tr>
<td><?php echo $lang['description'].": " ?></td>
<td><textarea name="description" placeholder="<?php echo $lang['description']."..." ?>" cols=50 rows=5></textarea></td>
</tr>
<tr>
<td><?php echo $lang['ministry_support'].": "?></td>
<td>
<?php
for($i=0; $i<3; $i++){
echo "<input type=\"radio\" name=\"ministry_support\" id=\"o_".$oid."\" value=\"".$i."\" required>";
echo "<label for=\"o_".$oid."\">".$lang['ministry_'.$i]."</label>";
echo "<br>";
$oid++;
}
?>
</td>
</tr>
<tr>
<td><?php echo $lang['ministry_place'].": " ?></td>
<td><input type="number" name="ministry_place" placeholder="<?php echo $lang['ministry_place']."..." ?>" min=0></td>
</tr>
</table>
<br>
<br>
<button type="submit" form="dd_edit_form"><?php echo $lang['ok'] ?></button>
<button type="button" onclick="contestsCancelEdit()"><?php echo $lang['cancel'] ?></button>
</form>
</div>
</div>
<hr class="placeholder">
<!-- list -->
<div id="listHolder">
<select id="schoolyear" onchange="contestsFilterApply()">
<?php
$sql=$db->prepare("SELECT DISTINCT schoolyear FROM contests WHERE schoolyear<>:current ORDER BY schoolyear ASC");
$sql->execute(array(":current"=>$schoolyear));
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
echo "<option value=\"".$row['schoolyear']."\">".$row['schoolyear']."</option>";
}
echo "<option value=\"".$schoolyear."\" selected>".$schoolyear."</option>";
?>
</select>
<div id="list" class="selfcenter">
<!-- list goes here -->
</div>
</div>
</div>