SignUp/subs/timetable_programs.php

79 lines
3.0 KiB
PHP
Raw Normal View History

2019-08-08 13:40:15 +00:00
<?php
/**
* /subs/timetable_programs.php
* @version 1.0
* @desc timetable based on programs
* @author Fándly Gergő Zoltán 2017
* @copy 2017 Fándly Gergő Zoltán
*/
?>
<div id="content">
<h2><?php echo $lang['timetable_programs'] ?></h2>
<hr class="placeholder">
<div id="printarea" style="width: 100%">
<center>
<div id="programs">
<?php
$sql=$db->prepare("SELECT p.id, p.name, p.instructor, p.location, 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 p.name ASC, ts.id ASC, tb.name ASC");
$sql->execute();
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
echo "<div style=\"page-break-after: always; page-break-inside: avoid; margin-bottom: 5em\">";
echo "<h3>".$row['name']."</h3>";
echo "<hr>";
echo "<p style=\"font-size: 0.8em\">".$lang['instructor'].": ".$row['instructor']." | ".$lang['location'].": ".$row['location']." | ".$lang['timeblock'].": ".$row['time_sequence']."/".$row['time_block']."</p>";
echo "<br>";
echo "<table class=\"table\">";
echo "<thead>";
echo "<tr>";
echo "<th data-breakpoints=\"xs sm\">".$lang['num']."</th>";
echo "<th>".$lang['name']."</th>";
echo "<th>".$lang['class']."</th>";
echo "</tr>";
echo "</thead>";
echo "<tbody>";
$num=1;
$sql2=$db->prepare("SELECT u.name, u.class FROM registrations AS r INNER JOIN users AS u ON (u.id=r.user) WHERE r.program=:pid ".$whereand." ORDER BY u.name ASC");
$sql2->execute(array(":pid"=>$row['id']));
while($row2=$sql2->fetch(PDO::FETCH_ASSOC)){
echo "<tr>";
echo "<td>".$num."</td>";
echo "<td>".$row2['name']."</td>";
echo "<td>".$row2['class']."</td>";
echo "</tr>";
}
echo "</tbody>";
echo "</table>";
echo "</div>";
}
?>
</div>
</center>
</div>
<hr class="placeholder">
<button type="button" onclick="window.location='./timetable_programs?print'"><?php echo $lang['print'] ?></button>
<?php if(isset($_GET['print'])): ?>
<style id="print">
body *{
visibility: hidden;
}
#printarea{
position: absolute;
left: 0;
top: 0;
}
#printarea, #printarea *{
visibility: visible;
}
</style>
<script>
setTimeout(function(){
window.print();
}, 2000);
</script>
<?php endif ?>
</div>