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

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<script type="text/javascript">
 function dynInput(cbox) {
  if (cbox.checked) {
    var input = document.createElement("input");
    input.type = "text";
    var div = document.createElement("div");
    div.id = cbox.name;
    div.innerHTML = "Text to display for " + cbox.name;
    div.appendChild(input);
    document.getElementById("insertinputs").appendChild(div);
  } else {
    document.getElementById(cbox.name).remove();
  }
}
</script>
<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>
<h2>ΑΝΑΠΛΗΡΩΣΕΙΣ</h2>

<?php
require "dbconnect.php"; 
$dt=$_SESSION['dt'];
echo "Ημερομηνία: ".$dt;
$name = $_SESSION['n'];
$name = stripslashes($name);
$gym=$_SESSION['gym'];
$day = date('D', strtotime($dt));
$sqanapl=$dbcon->prepare("SELECT * from apousieskath where datefrom <=$dt and dateto >=$dt");
$sqanapl->execute([$dt]);
$pmpx=$namet=$df=$dt=$pf=$pt=$reason=$adeia=array();
$i=1;
while ($rowa=$sqanapl->fetch(PDO::FETCH_ASSOC))
{
  $p=$rowa['pmp'];
  $pmpx[$p]=$rowa['pmp'];
  $df[$p]=$rowa['datefrom'];
  $df[$p]=$rowa['dateto'];
  $pf[$p]=$rowa['perfrom'];
  $pt[$p]=$rowa['perto'];
  $reason[$p]=$rowa['leptomeries'];
  $adeia[$p]=$rowa['notr'];
  $i++;	
}


?>
<h4> ΕΠΕΛΕΞΕ ΤΟΥΣ ΕΚΠΑΙΔΕΥΤΙΚΟΥΣ ΠΟΥ ΘΑ ΑΠΟΥΣΙΑΖΟΥΝ </h4>
<form   method='post' >
<div style="overflow:scroll; border:1px solid black;background:#F5F9F0;width:1150px; height: 450px">
<?php
echo "<table style='width:1130px' class='myTable' >
<tr style='border:1px solid black' bgcolor='#adcd82'  >
<th>A/A</th>
<th>ΚΑΘΗΓΗΤΗΣ/ΚΑΘΗΓΗΤΡΙΑ</th>
<th>ΑΠΟΥΣΙΑ</th>
<th>ΑΠΟ ΗΜΕΡ</th>
<th>ΜΕΧΡΙ ΗΜΕΡ</th>
<th>ΑΠΟ ΠΕΡ</th>
<th>ΜΕΧΡΙ ΠΕΡ</th>
<th>ΛΟΓΟΣ</th>
<th>ΑΔΕΙΑ</th>
</tr>";
$pmp=$namet=array();
$result = mysqli_query($con,"SELECT PMP,name FROM teachers where access <> 6 ORDER BY name ");
$i=1;
while ($row = mysqli_fetch_array($result)) 
  { 
    $namet[$i]=$row['name'];
	$p=$row['PMP'];	
	if(in_array($p,$pmpx) )
	{
	   $chk[$i] = "checked";
	   
	}
	else
	{
		$chk[$i] = "";
    }

	echo "<tr>";
	echo "<td>".$i."</td>";
	echo "<td>".$namet[$i]."</td>";
	?>
	<input type="checkbox" name='apon[]' <?php echo $chk[$i];?> onclick="dynInput(this);" />
	<id="insertinputs">
	
	<?php
	
	echo "</tr>";
    $i++;
}
echo "</table>";
?>
</div>
<br>
<input type="submit" name="anaplb" value="Επιβεβαίωση Επιλογών" >
</form>

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