187 lines
8.9 KiB
PHP
187 lines
8.9 KiB
PHP
<?php
|
|
/**
|
|
* /subs/timetable.php
|
|
* @version 1.0
|
|
* @desc Timetable sub
|
|
* @author Fándly Gergő Zoltán
|
|
* @copy 2017 Fándly Gergő Zoltán
|
|
*/
|
|
|
|
?>
|
|
|
|
<div id="content">
|
|
<?php if($_SESSION['accesslevel']>=2): ?>
|
|
<div id="forceadddiv">
|
|
<form class="ajaxform" method="POST" action="" id="forceadd" autocomplete="off">
|
|
<fieldset>
|
|
<legend><?php echo $lang['forceadd'] ?></legend>
|
|
<center>
|
|
<p><?php echo $lang['forceadddisc'] ?></p>
|
|
<table>
|
|
<tr>
|
|
<td><?php echo $lang['user'].": " ?></td>
|
|
<td>
|
|
<select name="fa_user" required>
|
|
<option value="-1" selected disabled><?php echo $lang['pleaseselect'] ?></option>
|
|
<?php
|
|
$sql=$db->prepare("SELECT id, name, class FROM users WHERE accesslevel=0 and id<>1 ORDER BY class ASC, name ASC");
|
|
$sql->execute();
|
|
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
|
|
echo "<option value=\"".$row['id']."\">".$row['class']." :: ".$row['name']."</option>";
|
|
}
|
|
?>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td><?php echo "<b>".$lang['orthis']."</b> ".$lang['class'].": " ?></td>
|
|
<td>
|
|
<select name="fa_class">
|
|
<option value="-1" selected disabled><?php echo $lang['pleaseselect'] ?></option>
|
|
<?php
|
|
$sql=$db->prepare("SELECT DISTINCT class FROM users WHERE accesslevel=0 and id<>1 ORDER BY class ASC");
|
|
$sql->execute();
|
|
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
|
|
echo "<option value=\"".$row['class']."\">".$row['class']."</option>";
|
|
}
|
|
?>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td><?php echo $lang['program'].": " ?></td>
|
|
<td>
|
|
<select name="fa_program" required>
|
|
<option value="-1" selected disabled><?php echo $lang['pleaseselect'] ?></option>
|
|
<?php
|
|
$sql=$db->prepare("SELECT p.id, p.name, ts.name AS time_sequence, tb.name AS time_block FROM programs AS p INNER JOIN time_blocks AS tb ON (tb.id=p.time_block) INNER JOIN time_sequences AS ts ON (ts.id=tb.sequence) ORDER BY ts.id ASC, tb.name ASC, p.name ASC");
|
|
$sql->execute();
|
|
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
|
|
echo "<option value=\"".$row['id']."\">".$row['time_sequence']."/".$row['time_block']." :: ".$row['name']."</option>";
|
|
}
|
|
?>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<br>
|
|
<br>
|
|
<button type="submit" form="forceadd"><?php echo $lang['ok'] ?></button>
|
|
</center>
|
|
</fieldset>
|
|
</form>
|
|
</div>
|
|
<hr class="placeholder">
|
|
<?php endif ?>
|
|
<h2><?php echo $lang['timetable'] ?></h2>
|
|
<br>
|
|
<?php if($_SESSION['accesslevel']<1): ?>
|
|
<table class="table">
|
|
<thead>
|
|
<tr>
|
|
<th data-breakpoints="xs sm"><?php echo $lang['id'] ?></th>
|
|
<th><?php echo $lang['name'] ?></th>
|
|
<th data-breakpoints="xs sm md"><?php echo $lang['description'] ?></th>
|
|
<th data-breakpoints="xs sm"><?php echo $lang['instructor'] ?></th>
|
|
<th data-breakpoints="xs sm"><?php echo $lang['location'] ?></th>
|
|
<th><?php echo $lang['timeblock'] ?></th>
|
|
<th data-breakpoints="xs"><?php echo $lang['actions'] ?></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php
|
|
while($row=$msql->fetch(PDO::FETCH_ASSOC)){
|
|
echo "<tr>";
|
|
echo "<td>".$row['id']."</td>";
|
|
echo "<td>".$row['name']."</td>";
|
|
echo "<td>".$row['description']."</td>";
|
|
echo "<td>".$row['instructor']."</td>";
|
|
echo "<td>".$row['location']."</td>";
|
|
echo "<td>".$row['time_sequence']."/".$row['time_block']."</td>";
|
|
echo "<td><button class=\"ajaxbutton\" type=\"button\" data-confirm=\"".$lang['qunsubscribe']."\" data-url=\"./programs?unsub=".$row['id']."\">".$lang['unsubscribe']."</button></td>";
|
|
echo "</tr>";
|
|
}
|
|
?>
|
|
</tbody>
|
|
</table>
|
|
<?php elseif($_SESSION['accesslevel']>=1): ?>
|
|
<table class="table">
|
|
<thead>
|
|
<tr>
|
|
<th data-breakpoints="xs sm"><?php echo $lang['uid'] ?></th>
|
|
<th><?php echo $lang['name'] ?></th>
|
|
<th><?php echo $lang['class'] ?></th>
|
|
<?php
|
|
$sql=$db->prepare("SELECT tb.id, ts.name AS time_sequence, tb.name AS time_block FROM time_blocks AS tb INNER JOIN time_sequences AS ts ON (ts.id=tb.sequence) ORDER BY ts.id ASC, tb.name ASC");
|
|
$sql->execute();
|
|
$tbs=array();
|
|
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
|
|
echo "<th data-breakpoints=\"xs sm\">".$row['time_sequence']."<br>".$row['time_block']."</th>";
|
|
array_push($tbs, $row['id']);
|
|
}
|
|
?>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php
|
|
while($row=$msql->fetch(PDO::FETCH_ASSOC)){
|
|
echo "<tr>";
|
|
echo "<td>".$row['id']."</td>";
|
|
echo "<td>".$row['name']."</td>";
|
|
echo "<td>".$row['class']."</td>";
|
|
$i=0;
|
|
$sql=$db->prepare("SELECT r.id AS regid, tb.id AS time_block, p.name FROM registrations AS r INNER JOIN programs AS p ON (p.id=r.program) INNER JOIN time_blocks AS tb ON (tb.id=p.time_block) WHERE r.user=:uid ORDER BY tb.sequence ASC, tb.name ASC");
|
|
$sql->execute(array(":uid"=>$row['id']));
|
|
while($row2=$sql->fetch(PDO::FETCH_ASSOC)){
|
|
while($row2['time_block']!=$tbs[$i]){
|
|
echo "<td>-</td>";
|
|
$i++;
|
|
}
|
|
echo "<td>";
|
|
echo $row2['name'];
|
|
if($_SESSION['accesslevel']>=2){
|
|
echo "<button class=\"ajaxbutton\" type=\"button\" data-confirm=\"".$lang['qdelete']."\" data-url=\"./timetable?delete=".$row2['regid']."\">".$lang['delete']."</button>";
|
|
}
|
|
echo "</td>";
|
|
$i++;
|
|
}
|
|
for(;$i<count($tbs); $i++){
|
|
echo "<td>-</td>";
|
|
}
|
|
echo "</tr>";
|
|
}
|
|
?>
|
|
</tbody>
|
|
</table>
|
|
<?php endif ?>
|
|
<hr class="placeholder">
|
|
<button type="button" onclick="window.location='./timetable?export'"><?php echo $lang['export'] ?></button>
|
|
<?php if($_SESSION['accesslevel']>=2 && $config['general']['programs_needed']!=0): ?>
|
|
<hr class="placeholder">
|
|
<h2><?php echo $lang['notcomplete'] ?></h2>
|
|
<table class="table">
|
|
<thead>
|
|
<tr>
|
|
<th data-breakpoints="xs sm"><?php echo $lang['uid'] ?></th>
|
|
<th><?php echo $lang['name'] ?></th>
|
|
<th><?php echo $lang['progcount'] ?></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php
|
|
$sql=$db->prepare("SELECT u.id, u.name, u.class, (SELECT COUNT(r.id) AS count FROM registrations AS r WHERE r.user=u.id) AS progcount FROM users AS u WHERE u.accesslevel=0 and u.id<>1 and (SELECT COUNT(r.id) AS count FROM registrations AS r WHERE r.user=u.id)<:pc GROUP BY (u.id)");
|
|
$sql->execute(array(":pc"=>$config['general']['programs_needed']));
|
|
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
|
|
echo "<tr>";
|
|
echo "<td>".$row['id']."</td>";
|
|
echo "<td>".$row['name']."</td>";
|
|
echo "<td>".$row['class']."</td>";
|
|
echo "<td>".$row['progcount']."</td>";
|
|
echo "</tr>";
|
|
}
|
|
?>
|
|
</tbody>
|
|
</table>
|
|
<?php endif ?>
|
|
</div>
|