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

<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>

.blink_me {
  animation: blinker 2s linear infinite;
  color:red;
  font-size:110%;
}

@keyframes blinker 
{
 0%   { opacity: 1.0; }
 50%  { opacity: 0.0; }
 100% { opacity: 1.0; }
}  
</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'];
$gym=$_SESSION['gym'];
$result = mysqli_query($con,"SELECT Teacher FROM dailytab where pmp='$usr'");
$row = mysqli_fetch_array($result);
$tch=trim($row['Teacher']);
$day="day";
$d1="day"."1";$d2=$day."2";$d3=$day."3";$d4=$day."4";$d5=$day."5";$d6=$day."6";$d7=$day."7";$d8=$day."8";$d9=$day."9";
$result = mysqli_query($con,"SELECT id,Teacher,".$d1.",".$d2.",".$d3.",".$d4.",".$d5.",".$d6.",".$d7.",".$d8.",".$d9." FROM dailytab ");

$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<=$gym;$i++) 
   {
      $in=$day.$i;
      $tprog[$id][$i]=$row["$in"];
	  if($row["$in"] <>"" AND !($id & 1))
	  {
	  	  $ar=explode("/",$row["$in"]);
		  $j++;
		  $room[$j]=$ar[0];
	  }
   }
}
$room=array_unique($room);
sort($room);

$n=count($room);
$t=$id;
////////
for ($i=1;$i<=$t;$i++) 
{
  for ($j=1;$j<=$gym;$j++) 
  {
        if( !($i & 1))
		{
		  if($tprog[$i][$j] <>"" )
		  {
			  $ar=explode("/",$tprog[$i][$j]);
			  $r=trim($ar[0]);
			  $roomin[$r][$j]=$teach[$i-1];
		  }
		 
		}
  }
  
}
ksort($roomin);
$rms=$_SESSION['rms'];
$ar=explode("/",$rms);
$rm=$ar[1];
$per=$ar[0];
/*for ($k=1;$k<=$gym;$k++)
{	

  if ($roomin[trim($rm)][$k] === $tch)
  {
	$in=$k;
  }
}*/
$p=$per+1;
$f=0;
for ($k=$p;$k<=$gym;$k++)
{	
  if (!empty($roomin[trim($rm)][$k]))
  {
	$f=1;
  }
}
if ($f==0 and $p < 7)
{
	?><span class="blink_me">ΕΙΣΤΕ ΤΕΛΕΥΤΑΙΟΣ/Α ΣΤΗΝ ΑΙΘΟΥΣΑ, ΠΑΡΑΚΑΛΩ ΚΛΕΙΣΤΕ ΤΙΣ ΣΥΣΚΕΥΕΣ</span><?php
}	
?>


</body>
</html>