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

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

$day = date('D', strtotime($dt));

include "createdtab.php";
include "readdailytab.php";
////////////////////////////// allages gia ddk - ekdilosi sxoliou
$sql=$dbcon->prepare("select * from offperiods where datefrom=? ") ;
$sql->execute([$dt]);
$c=$sql->rowCount();
if ($c > 0)
{
  $class=$classin=array();
  while($row=$sql->fetch(PDO::FETCH_ASSOC))
  {
  $perapo=$row['perapo'];
  $permexri=$row['permexri'];
  $tmf=$row['tmimafrom'];
  $tmt=$row['tmimamexri'];
  
  $sql1=$dbcon->prepare("select v.Class_id,t.Name from voithos as v,teachers as t where v.yt=t.PMP") ;
  $sql1->execute();
  $nt=$sql1->rowCount();
  $ct=0;
  while($row1=$sql1->fetch(PDO::FETCH_ASSOC))
   {
      $cl=$row1['Class_id'];
	  if($cl >= $tmf and $cl <= $tmt)
	  {
		$classin[$cl]=$row1['Name']; 
        $ct++;		
	  }
   }
   if ($ct==$nt) //ola ta tmimata tou sxoleiou
   {
	 $n=count($teach);  
     for ($i=1;$i<=$n;$i++) 
     {
	   for ($k=$perapo;$k<=$permexri;$k++)//empty all classes
	   {
			$tprog[$i][$k]="";
	   }
     }
     $n=count($teach);
	 for ($i=1;$i<=$n;$i+=2)  
     {
	   if (in_array($teach[$i],$classin))
	   {
		  $tmima=array_search($teach[$i],$classin);
		  for ($k=$perapo;$k<=$permexri;$k++)
			 {
		        $tprog[$i][$k]=$tmima;
			    $v=$i+1;
			    $tprog[$v][$k]="YT/Δ.Δ.Κ";
			 } 
       }
     }
   }
  }
   include "katahorisi.php";
  
   //////////////////////////////////   
}

include "amivread.php";
include "ensomatosi.php"; //ensomatosi allagon
include "katahorisi.php";
include "ensoanaplir.php";//ensomatosi anapliroseon
include "katahorisi.php";

?>
</body>
</html>