<?php
include "scrinit.php";
include $menu;
?><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:2px;font-size:11px; }
<p style="font-size:09px;"></p>
</style>
<body>

<h3>ΕΠΙΣΚΟΠΗΣΗ ΑΔΕΙΩΝ ΕΙΣΟΔΟΥ </h3>
<?php
date_default_timezone_set("Europe/Athens");
require "dbconnect.php";
$usr=$_SESSION['usr'];
$date=date('Y-m-d');
echo "<br>"."<br>";

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

echo $fhtml;         // output /display the form
echo "<br>"."<br>";

if (isset($_POST['dt'])) {
	$date=$_POST['dt'];
echo " ΑΔΕΙΕΣ ΕΙΣΟΔΟΥ ΠΟΥ ΕΚΔΟΘΗΚΑΝ ΣΤΙΣ "."<b>".date('d-m-Y', strtotime($date))."</b>"."<br>"."<br>";	
}
$sql1 = "SELECT ek.*,e.code,e.pmp FROM ekdilosi as ek,ekdilosistu as e 
WHERE ek.onoma='ΑΔΕΙΑ ΕΙΣΟΔΟΥ' AND ek.code=e.code AND (DATE_FORMAT(ek.date,'%Y-%m-%d')='$date') order by ek.date,ek.perapo" ;
if (!mysqli_query($con,$sql1)) {die('Error: ' . mysqli_error($con));   }
$res=mysqli_query($con,$sql1);
$c=mysqli_num_rows($res);

if ($c==0){echo " ΔΕΝ ΥΠΑΡΧΟΥΝ ΑΔΕΙΕΣ ΕΙΣΟΔΟΥ ΑΥΤΗ ΤΗΝ ΗΜΕΡΟΜΗΝΙΑ";}
else
{
echo "<table class='myTable' >
<tr style='border:1px solid black;font-size:9px'  >
<tr>
<th>Κωδικός</th>
<th>Μητρώο</th>

<th>Μαθητής/τρια</th>
<th>Τμήμα</th>
<th>Ημερομ.</th>
<th>Ώρα</th>
<th>Περίοδ.</th>
<th>Βοηθός</th>
</tr>";	

while ($row = mysqli_fetch_array($res)) 
{
	$code=$row['code'];
	$mitr=$row['pmp'];
	$perapo=$row['perapo'];
	$voithos=$row['teacher'];
	$date=$row['date'];
	$time=$row['time'];
	$sql = mysqli_query($con,"SELECT eponimo,onoma,tmima FROM allstudentinfo WHERE mitroo='$mitr'  " );
    $row1 = mysqli_fetch_array($sql);
    $stname=$row1['eponimo']." ".$row1['onoma'];
    $tmimaid=$row1['tmima'];
	
	
	$sqlx=mysqli_query($con,"SELECT Name from teachers WHERE  PMP='$voithos' " );
    $row2 = mysqli_fetch_array($sqlx);
    $vdname=$row2['Name'];
	$xc=$code."/".$date."/".$mitr."/".$perapo;

echo "<tr>";
echo "<td>" .  "<a href=\"editadeiain.php?data=".$xc."\">"."<b>".$code."</b>". "</a>". "</td>";
echo "<td>" . $mitr. "</td>";
echo "<td>" . $stname. "</td>";
echo "<td align='center'>" . $tmimaid. "</td>";
echo "<td>" . $date. "</td>";
echo "<td>" . $time. "</td>";
echo "<td align='center'>" . $perapo. "</td>";
echo "<td>" . $vdname. "</td>";
echo "</tr>"; 
	
	//.............................................
}
echo "</table>";
echo "<br>"."<br>";
}
 ?>
 <br /> <br />
<a  href=<?php echo $menu;?> style="color:blue "  > <button> Επιστροφή στο Μενού   </a> 
</body>
</html>