<?php
include "scrinit.php";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ΑΠΟΥΣΙΟΛΟΓΙΟ ΕΚΠΑΙΔΕΥΤΙΚΟΥ</title>
<style type="text/css">
table.myTable { border-collapse:collapse; }
table.myTable td, table.myTable th { border:1px solid black;padding:2px;font-size:11pt; }
<p style="font-size:11px;"></p>
</style>
<!-- Be sure to place the above styles (i.e. everything between the <style></style> tags) into the document 'head' (i.e. between the <head></head> tags. Everything below goes inside the <body></body> tags) -->

</head>
<body>


<?php 
require "dbconnect.php"; 
$dt=$_SESSION['dt'];
$gym=$_SESSION['gym'];
if (isset($_POST['dt'])) {
	$dt=$_POST['dt'];
}
// define the form into a variable
$fhtml = '<form action="" method="post">
Επέλεξε Ημερομηνία: <input type="date" name="dt" value="'. $dt. '" />
 <input type="submit" value="Επιλογή Ημερομηνίας" />
</form>';
echo $fhtml;         // output /display the form
echo "<br>"."<br>";
if (isset($_POST['dt'])) {
	$dt=$_POST['dt'];
$_SESSION['dt']=$dt;

$day = date('D', strtotime($dt));
$sql = $dbcon->prepare("SELECT gymnasio FROM parameters" ); 
	$sql->execute();
	$row=$sql->fetch(PDO::FETCH_ASSOC);
	switch ($row['gymnasio']) {
	  case "1":    $gym= 8;    break;
	  case "2":    $gym= 7;    break;
	  case "3":    $gym= 9;    break;
	}
	$_SESSION['gym']=$gym;
	$_SESSION['gymx']=$gym; 
	$_SESSION['dt']=$dt;
include "allagiprog.php";

//.........................
for ($i=1;$i<=$gym;$i++)
{
	$dd[$i]="day".$i;
}
if ($day=="Sat" or $day=="Sun")
{
    echo "<br>"."ΔΕΝ ΥΠΑΡΧΟΥΝ ΜΑΘΗΜΑΤΑ ΣΗΜΕΡΑ"."<br>";
}
else 
{ 
$fields = implode(",", $dd);

$result = $dbcon->prepare("SELECT pmp,id,Teacher,".$fields." FROM dailytab ");
$result->execute();
$tpmp=array();
$j=1;
$d=$gym+1;
$xc="";
$row=$result->fetch(PDO::FETCH_ASSOC);
while (!empty($row))
{
   $id=$row['id'];
   $xc="";
   for ($i=1;$i<=$d;$i++) 
   {
      $in="day".$i;
      $tprog[$id][$i]=$row["$in"];
	  $xc=$xc.$row["$in"];
   }
   if (!empty($xc))
   {
	 $tpmp[$j]=$row['pmp'];
	 $j++;
   }
   $row=$result->fetch(PDO::FETCH_ASSOC);
   $row=$result->fetch(PDO::FETCH_ASSOC);
}


//........................
$limit=count($tpmp);
$i=1;
for ($x=1;$x<=$limit;$x++)
{
	$pmp=$tpmp[$x];
	$sql=$dbcon->prepare("select Name,sign from teachers where PMP=?");
	$sql->execute([$pmp]);
	$row=$sql->fetch(PDO::FETCH_ASSOC);
	$teach=$row['Name'];
	$signt=$row['sign'];
	echo "<p>"."ΚΑΘΗΓΗΤΗΣ/ΤΡΙΑ : ";
	echo "<font face='arial' size='4pt'> $teach </font> ";
	echo "</p>" ;
	$teacher=$teach;
	$usr=$pmp;
	
	include "apousiologioproc.php";
	
	$sign="signs/".$signt;
	?> 
	<br ><br >

	<img src=<?php echo $sign;?>  />
	<br>
	<?php
	echo ".........................."."<br>";
	echo "<font face='arial' size='2pt'> $teach </font> ";  
    echo "<br>"."<br>"."---------------------------------------------------------------------------------"."<br>";
	
}
echo "<br>"."<br>";
}
}
?>
<br ><br ><br >
<a  href=<?php echo $menu;?>  style="color:blue "  > <button> Επιστροφή στο Μενού  </a>
</body>
</html>