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

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="style1.css" rel="stylesheet" type="text/css" />

<script type="text/javascript" src="https://code.jquery.com/jquery-1.9.1.min.js"></script>
</script>

</head>

<body>

<?php
require "dbconnect.php"; 
$dt=$_SESSION['dt'];
$name = $_SESSION['n'];
$usr=$_SESSION['usr'];
$access=$_SESSION['access'];

echo "<p class='p1'>". "ΕΠΑΦΕΣ ΚΑΙ ΚΡΟΥΣΜΑΤΑ". "</p>";
$q=mysqli_query($con,"select tmima,count(tmima) as c from allstudentinfo group by tmima");
$i=1;
while($row=mysqli_fetch_array($q))
	{
	 $t[$row['tmima']]=$row['c'];
	 $i++;
	}
$q=mysqli_query($con,"select s.*,a.tmima,a.eponimo,a.onoma from spiticovid as s, allstudentinfo as a 
where s.mitroo=a.mitroo order by s.dateback,a.tmima");
$c=mysqli_num_rows($q);
echo "<table class='myTable3' >
<tr> 
<th>a/a</th>
<th>ΤΜΗΜΑ</th>
<th>ΚΡΟΥΣΜΑ</th>
<th>ΕΠΑΦΗ</th>
<th>ΕΠΙΣΤΡΕΦΕΙ</th>
</tr>";

if ($c==0)
{
	echo "<p class='p2'>". "ΔΕΝ ΥΠΑΡΧΟΥΝ ". "</p>";
}
else
{
	$i=1;
	while($row=mysqli_fetch_array($q))
	{
		
		$n=$row['eponimo']." ".$row['onoma'];
		$tmima=$row['tmima'];
		$r=$row['reason'];
		$din=date('d-m-Y', strtotime($row['dateback']));
		echo "<tr>";
		echo "<td>". $i."</td>";
		echo "<td>". $tmima."</td>";
		
		if ($r=='1')
		{
			echo "<td>". $n."</td>";
			echo "<td>". " "."</td>";
		}
		if ($r=='2')
		{
		    echo "<td>". " "."</td>";
			echo "<td>". $n."</td>";
			
		}
		echo "<td>". $din."</td>";
		echo "</tr>";		
		$i++;
	}
	echo "<table>";

}


?>
</body>
</html>