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

97 lines
3.1 KiB
PHP

<?php
/**
* /subs/classes_backend.php
* @version 1.2
* @desc backend for classes
* @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/>.
**/
try{
if(isset($_GET['list'])){
$filter="WHERE id<>1 and class<>''";
$filter_array=array();
if(isset($_POST['filter'])){
if(isset($_POST['f_search'])){
if($_POST['f_search']!=""){
$filter.=" and (class LIKE ? or username LIKE ? or fullname LIKE ?)";
array_push($filter_array, "%".$_POST['f_search']."%", "%".$_POST['f_search']."%", "%".$_POST['f_search']."%");
}
}
}
$sql=$db->prepare("SELECT fullname, accesslevel, class FROM users ".$filter." ORDER BY class ASC, accesslevel DESC, fullname ASC");
$sql->execute($filter_array);
//echo table(s)
$first=true;
$rid=0;
$curClass="";
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
if($curClass!=$row['class']){
$curClass=$row['class'];
if(!$first){
echo "
</tbody>
</table>
<hr class=\"placeholder\">
";
}
if($first){
$first=false;
}
$rid=1;
echo "
<div class=\"center\">
<h2>".$curClass."</h2>
</div>
<hr>
<table class=\"table\">
<thead>
<tr>
<th>".$lang['rowid']."</td>
<th>".$lang['fullname']."</td>
<th data-breakpoints=\"xs sm\">".$lang['role']."</td>
</tr>
</thead>
<tbody>
";
}
echo "
<tr>
<td>".$rid."</td>
<td>".$row['fullname']."</td>
<td>".($row['accesslevel']>0?$lang['headteacher']:$lang['student'])."</td>
</tr>
";
$rid++;
}
echo "
</tbody>
</table>
";
}
}
catch(Exception $e){
functions::setError(500);
error_log($e);
}