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

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>

</head>
<style type="text/css">
table.myTable { border-collapse:collapse; }
table.myTable td, table.myTable th { border:1px solid green;padding:2px;font-size:10pt; }
<p style="font-size:10px;"></p>
</style>
<body>
<h3>ΑΠΟΝΤΕΣ ΜΑΘΗΤΕΣ/ΤΡΙΕΣ</h3>

<?php
require "dbconnect.php"; 
$dt=$_SESSION['dt'];
echo "Ημερομηνία: ".date('d-m-Y', strtotime($dt));
$name = $_SESSION['n'];
$day = date('D', strtotime($dt));
$sq=$dbcon->prepare("SELECT * from apontestil where datefrom <='$dt' and dateto >='$dt' ");
$sq->execute([$dt]);
$mitroox=$namet=$df=$dtx=$logos=$mred=$chk=$chk2=$chk3=array();
$i=1;
while ($row=$sq->fetch(PDO::FETCH_ASSOC))
{
  $p=$row['mitroo'];
  $mitroox[$p]=$p;
  $df[$p]=$row['datefrom'];
  $dtx[$p]=$row['dateto'];
  if ($df[$p]==$dt or ($dt >= $df[$p] and $dt <= $dtx[$p]))
  {
	$mred[$p]='red';
  }
  $logos[$p]=$row['logos'];
  $i++;	
}

?>
<h4> ΕΠΕΛΕΞΕ ΤΟΥΣ ΜΑΘΗΤΕΣ ΠΟΥ ΤΗΛΕΦΩΝΗΣΑΝ ΟΤΙ ΘΑ ΑΠΟΥΣΙΑΖΟΥΝ </h4>
<form   method='post' action='apontestil1.php'>
<div style="overflow:scroll; border:1px solid black;background:#F5F9F0;width:601px; height: 550px">
<?php
echo "<table style='width:600px' class='myTable' >
<tr style='border:1px solid black' bgcolor='#adcd82'  >
<th>A/A</th>
<th>ΤΜΗΜΑ</th>
<th>ΜΗΤΡΩΟ</th>
<th>ΜΑΘΗΤΗΣ/ΤΡΙΑ</th>
<th>ΑΠΟΥΣΙΑ</th>
</tr>";
$namet=array();
$result = mysqli_query($con,"SELECT mitroo,tmima,eponimo,onoma FROM allstudentinfo ORDER BY tmima,eponimo,onoma");
$i=1;
while ($row = mysqli_fetch_array($result)) 
  { 
    $namet[$i]=$row['eponimo']." ".$row['onoma'];
	$p=$row['mitroo'];
	$tm[$i]=$row['tmima'];
	if(in_array($p,$mitroox) )
	{
	   $chk[$i] = "checked"; 
	}
	else
	{
		$chk[$i] = "";
    }

	if ($mred[$p]=='red')
	{
		echo "<tr style='background-color:#FF0000'>";	
	}
	else
	{
		echo "<tr>";	
	}
	
	echo "<td>".$i."</td>";
	echo "<td >".$tm[$i]."</td>";
	echo "<td >".$p."</td>";
	echo "<td >".$namet[$i]."</td>";
	echo "<td ALIGN=center>"."<input type='checkbox' name='apon[]' value='$p'  {$chk[$i]} >"."</td>";
	echo "</tr>";
    $i++;
}
echo "</table>";

?>
</div>
<br>
<input type="submit" name="aponk" value="Επιβεβαίωση Επιλογών" >
</form>

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