<?php
include "scrinit.php";
include $menu;
?>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
table.myTable { border-collapse:collapse; }
table.myTable td, table.myTable th { border:1px solid black;padding:2px;font-size:12pt; }
<p style="font-size:11px;"></p>
</style>

</script>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script type="text/javascript">
$(function() {
 $("#tmimaid").bind("change", function() {
     $.ajax({
         url: "change.php",
         data: "tmimaid="+$("#tmimaid").val(),
         success: function(html) {
             $("#nameid").html(html);
         }
     });
 }); 
});

function popupCenter(pageURL, title, w, h) {
    var left = (screen.width / 2)  - (w / 2);
    var top  = (screen.height / 2) - (h / 2);
    var targetWin = window.open(pageURL, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=900, height=300, top='+top+', left='+left);
}
</script>




</head>
<body>
<h3>Καθηγητές ανα τάξη</h3>

<?php 
require("dbconnect.php");
$dt=$_SESSION['dt'];
$gym=$_SESSION['gym'];
?>

<form method="post" name = "form1">
ΗΜΕΡΟΜΗΝΙΑ: <input type="date"  name = 'dt' value= <?php echo $dt; ?> > 
&nbsp;&nbsp;&nbsp
ΤΑΞΗ:<select name="taxi">
		 <option value="Α">Α</option>
		 <option value="Β">Β</option>
		 <option value="Γ">Γ</option>
	 </select>
&nbsp;&nbsp;&nbsp
<input type="submit" name="submit1" value="Επιβεβαίωση Επιλογής" >
</form>

<?php

if(isset($_POST['submit1']))
{
$dt=$_POST['dt'];
$_SESSION['dt']=$dt;
$taxi=$_POST['taxi'];
require "allagiprog.php";
$day = date('D', strtotime($dt));
$i=0;
for ($k=1;$k<=$gym;$k++)
{
	$d="day".$k;
	$sqly = mysqli_query($con,"SELECT id,pmp,Teacher,".$d." FROM dailytab 
	where id % 2 =1 AND (".$d." !='' OR ".$d." > ' ') AND ".$d." like '$taxi%' ");
    
	while($rowy = mysqli_fetch_array($sqly))
	{
		 $id=$rowy['id'];
		 $nid=$id+1;
		 $i++;
		 $pm[$rowy['pmp']]=$rowy['pmp'];
		 $name[$rowy['pmp']]=$rowy['Teacher'];
		 $tmima=$rowy["$d"];
		 $sqly1 = mysqli_query($con,"SELECT ".$d." FROM dailytab where id='$nid' ");
		 $rowy1 = mysqli_fetch_array($sqly1);
		 $room= $rowy1["$d"];
		 $arr = explode("/", $room);
		 $subject=$arr[1];
		 $rm = $arr[0];
		 $tpmp[$rowy['pmp']][$k]=$tmima." /".$subject;
	 }
}
$cc=count($pm);
echo "<br>";
echo "ΚΑΤΑΛΟΓΟΣ ΔΙΔΑΣΚΟΝΤΩΝ"."<br>";
echo "<table class='myTable' >
<tr style='border:1px solid black' bgcolor='#d6ff73'  >
<th>ΑΑ</th>
<th>ΚΑΘΗΓΗΤΗΣ</th>";
for ($i=1;$i<=$gym;$i++)
{
	$titep="Περ".$i;
	echo "<th>".$titep."</th>";
}
echo "</tr>";
$k=1;
foreach ($pm as $pmx)
{
	echo "<tr>";
	echo "<td>".$k."</td>";
	echo "<td>".$name[$pmx]."</td>";
	for ($i=1;$i<=$gym;$i++)
	{
		echo "<td>".$tpmp[$pmx][$i]."</td>";
	}
	echo "</tr>";
	$k++;
}
echo "</table>";	
}
?>

<br /><br />
<a  href=<?php echo $menu;?> style="color:blue "  > <button> Επιστροφή στο Μενού  </a>
</body>
</html>