<?php
session_start();
ob_start();
if ($_SESSION['islogin']=='' ) { 
  echo "ΠΡΕΠΕΙ ΝΑ ΕΓΓΡΑΦΕΙΤΕ ΓΙΑ ΝΑ ΧΡΗΣΙΜΟΠΟΙΗΣΕΤΕ ΤΟ ΣΥΣΤΗΜΑ"."<BR>";
  sleep(3);
  header("Location: loginall.php"); /* Redirect browser */
  exit();
  }
$menu = $_SESSION['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:1px;font-size:10pt; }
<p style="font-size:10px;"></p>
</style>

</script>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script type="text/javascript">
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>

<?php 

require("dbconnect.php");
$dt=$_SESSION['dt'];
echo "Date:".$dt;
$day = date('D', strtotime($dt));

//............................
//include "allagiprog.php";
//.......................

$d1=$day."1";$d2=$day."2";$d3=$day."3";$d4=$day."4";$d5=$day."5";$d6=$day."6";$d7=$day."7";
$result = mysqli_query($con,"SELECT id,Teacher,".$d1.",".$d2.",".$d3.",".$d4.",".$d5.",".$d6.",".$d7." FROM timetable ");

$tprog=array();$teach=array();$room=array();
$j=0;
while ($row = mysqli_fetch_array($result))
{
   $id=$row['id'];
   $teach[$id]=$row['Teacher'];
   for ($i=1;$i<=7;$i++) 
   {
      $in=$day.$i;
      $tprog[$id][$i]=$row["$in"];
	  if($row["$in"] <>"" AND !($id & 1)){
	  	  $ar=explode("/",$row["$in"]);
		  $j++;
		  $room[$j]=$ar[0];
		  }
   }
}

echo "<table style='width:1000px' class='myTable' >
<tr style='border:1px solid black' bgcolor='#FFAF80'  >
<th>ID</th>
<th>Όνομα</th>
<th>Περ1</th>
<th>Περ2</th>
<th>Περ3</th>
<th>Περ4</th>
<th>Περ5</th>
<th>Περ6</th>
<th>Περ7</th>
</tr>";

$n=count($teach);
for ($i=1;$i<=$n;$i++) 
   {
      echo "<tr>";
	  echo "<td>". $i . "</td>";
	  echo "<td>". $teach[$i] . "</td>";
	  for ($k=1;$k<=7;$k++) 
         {
           echo "<td>". $tprog[$i][$k] . "</td>";
         }
      echo "</tr>";
   }  
echo "</table>";	 
//....................................

?>

</body>
</html>