246 lines
13 KiB
PHP
246 lines
13 KiB
PHP
|
<?php
|
||
|
/**
|
||
|
* /subs/programs.php
|
||
|
* @version 1.0
|
||
|
* @desc programs
|
||
|
* @author Fándly Gergő Zoltán
|
||
|
* @copy 2017 Fándly Gergő Zoltán
|
||
|
*/
|
||
|
|
||
|
$oid=0;
|
||
|
|
||
|
?>
|
||
|
|
||
|
<div id="content">
|
||
|
<?php if($_SESSION['accesslevel']>=2): ?>
|
||
|
<div id="admintools">
|
||
|
<div id="tool_newprogram">
|
||
|
<form class="ajaxform" method="POST" action="" id="newprogram">
|
||
|
<fieldset>
|
||
|
<legend><?php echo $lang['newprogram'] ?></legend>
|
||
|
<center>
|
||
|
<table>
|
||
|
<tr>
|
||
|
<td><?php echo $lang['name'].": " ?></td>
|
||
|
<td><input type="text" name="n_name" placeholder="<?php echo $lang['name']."..." ?>" required></td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td><?php echo $lang['description'].": " ?></td>
|
||
|
<td><textarea name="n_description" placeholder="<?php echo $lang['description']."..." ?>" rows=10 cols=40></textarea></td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td><?php echo $lang['instructor'].": " ?></td>
|
||
|
<td><input type="text" name="n_instructor" placeholder="<?php echo $lang['instructor']."..." ?>" required></td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td><?php echo $lang['location'].": " ?></td>
|
||
|
<td><input type="text" name="n_location" placeholder="<?php echo $lang['location']."..." ?>" required></td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td><?php echo $lang['category'].": " ?></td>
|
||
|
<td>
|
||
|
<input type="radio" name="n_category" value="100" id="o_<?php echo $oid ?>" required><label for="o_<?php echo $oid; $oid++ ?>"><?php echo $lang['cat'][100] ?></label><br>
|
||
|
<input type="radio" name="n_category" value="0" id="o_<?php echo $oid ?>" required><label for="o_<?php echo $oid; $oid++ ?>"><?php echo $lang['cat'][0] ?></label><br>
|
||
|
<input type="radio" name="n_category" value="1" id="o_<?php echo $oid ?>" required><label for="o_<?php echo $oid; $oid++ ?>"><?php echo $lang['cat'][1] ?></label><br>
|
||
|
<input type="radio" name="n_category" value="2" id="o_<?php echo $oid ?>" required><label for="o_<?php echo $oid; $oid++ ?>"><?php echo $lang['cat'][2] ?></label><br>
|
||
|
<input type="radio" name="n_category" value="3" id="o_<?php echo $oid ?>" required><label for="o_<?php echo $oid; $oid++ ?>"><?php echo $lang['cat'][3] ?></label><br>
|
||
|
<input type="radio" name="n_category" value="4" id="o_<?php echo $oid ?>" required><label for="o_<?php echo $oid; $oid++ ?>"><?php echo $lang['cat'][4] ?></label><br>
|
||
|
<input type="radio" name="n_category" value="5" id="o_<?php echo $oid ?>" required><label for="o_<?php echo $oid; $oid++ ?>"><?php echo $lang['cat'][5] ?></label><br>
|
||
|
<input type="radio" name="n_category" value="6" id="o_<?php echo $oid ?>" required><label for="o_<?php echo $oid; $oid++ ?>"><?php echo $lang['cat'][6] ?></label><br>
|
||
|
<input type="radio" name="n_category" value="10" id="o_<?php echo $oid ?>" required><label for="o_<?php echo $oid; $oid++ ?>"><?php echo $lang['cat'][10] ?></label><br>
|
||
|
<input type="radio" name="n_category" value="11" id="o_<?php echo $oid ?>" required><label for="o_<?php echo $oid; $oid++ ?>"><?php echo $lang['cat'][11] ?></label><br>
|
||
|
<input type="radio" name="n_category" value="12" id="o_<?php echo $oid ?>" required><label for="o_<?php echo $oid; $oid++ ?>"><?php echo $lang['cat'][12] ?></label><br>
|
||
|
<input type="radio" name="n_category" value="20" id="o_<?php echo $oid ?>" required><label for="o_<?php echo $oid; $oid++ ?>"><?php echo $lang['cat'][20] ?></label>
|
||
|
</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td><?php echo $lang['timeblock'].": " ?></td>
|
||
|
<td>
|
||
|
<?php
|
||
|
$sql=$db->prepare("SELECT tb.id, ts.name AS ts_name, tb.name AS tb_name FROM time_blocks AS tb INNER JOIN time_sequences AS ts ON (ts.id=tb.sequence)");
|
||
|
$sql->execute();
|
||
|
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
|
||
|
echo "<input type=\"radio\" name=\"n_timeblock\" value=\"".$row['id']."\" id=\"o_".$oid."\" required><label for=\"o_".$oid."\">".$row['ts_name']."/".$row['tb_name']."</label><br>";
|
||
|
$oid++;
|
||
|
}
|
||
|
?>
|
||
|
</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td><?php echo $lang['maxpart'].": " ?></td>
|
||
|
<td><input type="number" name="n_maxpart" placeholder="<?php echo $lang['maxpart']."..." ?>" required min=1></td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
<br>
|
||
|
<br>
|
||
|
<button type="submit" form="newprogram"><?php echo $lang['ok'] ?></button>
|
||
|
</center>
|
||
|
</fieldset>
|
||
|
</form>
|
||
|
</div>
|
||
|
<br>
|
||
|
<div id="tool_newtimesequence">
|
||
|
<form class="ajaxform" method="POST" action="" id="newtimesequence" autocomplete="off">
|
||
|
<fieldset>
|
||
|
<legend><?php echo $lang['newtimesequence'] ?></legend>
|
||
|
<center>
|
||
|
<table>
|
||
|
<tr>
|
||
|
<td><?php echo $lang['name'].": " ?></td>
|
||
|
<td><input type="text" name="nts_name" placeholder="<?php echo $lang['name']."..." ?>" required></td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
<br>
|
||
|
<br>
|
||
|
<button type="submit" form="newtimesequence"><?php echo $lang['ok'] ?></button>
|
||
|
</center>
|
||
|
</fieldset>
|
||
|
</form>
|
||
|
<br>
|
||
|
<table class="table" id="ts_table">
|
||
|
<thead>
|
||
|
<tr>
|
||
|
<th><?php echo $lang['id'] ?></th>
|
||
|
<th><?php echo $lang['name'] ?></th>
|
||
|
<th><?php echo $lang['actions'] ?></th>
|
||
|
</tr>
|
||
|
</thead>
|
||
|
<tbody>
|
||
|
<?php
|
||
|
$sql=$db->prepare("SELECT id, name FROM time_sequences ORDER BY name ASC");
|
||
|
$sql->execute();
|
||
|
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
|
||
|
echo "<tr>";
|
||
|
echo "<td>".$row['id']."</td>";
|
||
|
echo "<td>".$row['name']."</td>";
|
||
|
echo "<td>";
|
||
|
echo "<button class=\"ajaxbutton\" type=\"button\" data-confirm=\"".$lang['qdelete']."\" data-url=\"./programs?ts_delete=".$row['id']."\">".$lang['delete']."</button>";
|
||
|
echo "</td>";
|
||
|
echo "</tr>";
|
||
|
}
|
||
|
?>
|
||
|
</tbody>
|
||
|
</table>
|
||
|
</div>
|
||
|
<br>
|
||
|
<div id="tool_newtimeblock">
|
||
|
<form class="ajaxform" method="POST" action="" id="newtimeblock" autocomplete="off">
|
||
|
<fieldset>
|
||
|
<legend><?php echo $lang['newtimeblock'] ?></legend>
|
||
|
<center>
|
||
|
<table>
|
||
|
<tr>
|
||
|
<td>
|
||
|
<?php echo $lang['name'].": " ?>
|
||
|
<br>
|
||
|
<span style="font-size: 0.8em"><?php echo $lang['time_block_disclaimer'] ?></span>
|
||
|
</td>
|
||
|
<td><input type="text" name="ntb_name" placeholder="<?php echo $lang['name']."..." ?>" required></td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td><?php echo $lang['timesequence'].": " ?></td>
|
||
|
<td>
|
||
|
<?php
|
||
|
$sql=$db->prepare("SELECT id, name FROM time_sequences ORDER BY name ASC");
|
||
|
$sql->execute();
|
||
|
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
|
||
|
echo "<input type=\"radio\" name=\"ntb_timesequence\" value=\"".$row['id']."\" id=\"o_".$oid."\" required><label for=\"o_".$oid."\">".$row['name']."</label><br>";
|
||
|
$oid++;
|
||
|
}
|
||
|
?>
|
||
|
</td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
<br>
|
||
|
<br>
|
||
|
<button type="submit" form="newtimeblock"><?php echo $lang['ok'] ?></button>
|
||
|
</center>
|
||
|
</fieldset>
|
||
|
</form>
|
||
|
<br>
|
||
|
<table class="table" id="tb_table">
|
||
|
<thead>
|
||
|
<tr>
|
||
|
<th><?php echo $lang['id'] ?></th>
|
||
|
<th><?php echo $lang['timesequence'] ?></th>
|
||
|
<th><?php echo $lang['name'] ?></th>
|
||
|
<th><?php echo $lang['actions'] ?></th>
|
||
|
</tr>
|
||
|
</thead>
|
||
|
<tbody>
|
||
|
<?php
|
||
|
$sql=$db->prepare("SELECT tb.id, tb.name, ts.name AS time_sequence FROM time_blocks AS tb INNER JOIN time_sequences AS ts ON (ts.id=tb.sequence) ORDER BY ts.name ASC, tb.name ASC");
|
||
|
$sql->execute();
|
||
|
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
|
||
|
echo "<tr>";
|
||
|
echo "<td>".$row['id']."</td>";
|
||
|
echo "<td>".$row['time_sequence']."</td>";
|
||
|
echo "<td>".$row['name']."</td>";
|
||
|
echo "<td>";
|
||
|
echo "<button class=\"ajaxbutton\" type=\"button\" data-confirm=\"".$lang['qdelete']."\" data-url=\"./programs?tb_delete=".$row['id']."\">".$lang['delete']."</button>";
|
||
|
echo "</td>";
|
||
|
echo "</tr>";
|
||
|
}
|
||
|
?>
|
||
|
</tbody>
|
||
|
</table>
|
||
|
</div>
|
||
|
</div>
|
||
|
<hr class="placeholder">
|
||
|
<?php endif ?>
|
||
|
<h2><?php echo $lang['programs_content'] ?></h2>
|
||
|
<br>
|
||
|
<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 data-breakpoints="xs"><?php echo $lang['category'] ?></th>
|
||
|
<th><?php echo $lang['timeblock'] ?></th>
|
||
|
<th data-breakpoints="xs sm"><?php echo $lang['maxpart'] ?></th>
|
||
|
<th data-breakpoints="xs sm"><?php echo $lang['curpart'] ?></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>".$lang['cat'][$row['category']]."</td>";
|
||
|
echo "<td>".$row['time_sequence']."/".$row['time_block']."</td>";
|
||
|
echo "<td>".$row['max_participants']."</td>";
|
||
|
echo "<td>".$row['cur_participants']."</td>";
|
||
|
|
||
|
echo "<td>";
|
||
|
if($_SESSION['accesslevel']<1){
|
||
|
if($row['cur_participants']<$row['max_participants']){
|
||
|
echo "<button class=\"ajaxbutton\" type=\"button\" data-url=\"./programs?sub=".$row['id']."\">".$lang['subscribe']."</button>";
|
||
|
}
|
||
|
else{
|
||
|
echo "-";
|
||
|
}
|
||
|
}
|
||
|
else if($_SESSION['accesslevel']>=2){
|
||
|
echo "<button class=\"ajaxbutton\" type=\"button\" data-confirm=\"".$lang['qdelete']."\" data-url=\"./programs?delete=".$row['id']."\">".$lang['delete']."</button>";
|
||
|
}
|
||
|
else{
|
||
|
echo "-";
|
||
|
}
|
||
|
echo "</td>";
|
||
|
echo "</tr>";
|
||
|
}
|
||
|
?>
|
||
|
</tbody>
|
||
|
</table>
|
||
|
<hr class="placeholder">
|
||
|
<button type="button" onclick="window.location='./programs?export'"><?php echo $lang['export'] ?></button>
|
||
|
</div>
|