<?php
include "scrinit.php";
include 'logo.php';
?>

<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:10pt; }
<p style="font-size:10px;"></p>
</style>

</head>

<body>
<h4> ΑΠΟΥΣΙΕΣ ΠΡΟΣ ΔΙΕΡΕΥΝΗΣΗ</h4>

<?php
$dt=$_SESSION['dt'];
$day = date('D', strtotime($dt));
$gym=$_SESSION['gym'];
$usr=$_SESSION['usr'];
$ac=$_SESSION['access'];
if ($ac==4)
{	
require "allagiprog.php";
$sqlz = mysqli_query($con,"select count(a.period) as cp,a.mitroo,al.tmima,CONCAT(al.eponimo,' ',al.onoma) as stnam,t.Name
from apousies as a,allstudentinfo as al,voithos as v,teachers as t where (a.dateout='$dt' and a.apousia=1 and a.mitroo > 0 
and al.mitroo=a.mitroo and v.Class_id=al.tmima and t.PMP=v.voi_id ) group by mitroo having count(period) < 7 order by mitroo DESc "); 
}
else
{
require "allagiprog.php";
$sqlz = mysqli_query($con,"select count(a.period) as cp,a.mitroo,al.tmima,CONCAT(al.eponimo,' ',al.onoma) as stnam,t.Name
from apousies as a,allstudentinfo as al,voithos as v,teachers as t where (a.dateout='$dt' and a.apousia=1 and a.mitroo > 0 
and al.mitroo=a.mitroo and v.Class_id=al.tmima and t.PMP=v.voi_id and v.voi_id='$usr') group by mitroo having count(period) < 7 order by mitroo DESc "); 	
}


$nr=mysqli_num_rows($sqlz);
if ( $nr> 0)
{
	echo "<table class='myTable' >
	<tr style='border:1px solid black' bgcolor='#d6ff73'  >
	<th>Περ εκτός</th>
	<th>Μητρωο</th>
	<th>Τμήμα</th>
	<th>ΒΔ</th>
	<th>Όνομα</th>";
	while($row = mysqli_fetch_array($sqlz)) 
	{
		  echo "<tr>";
		  $plithos=$row['cp'];
		  $mitroo=$row['mitroo'];
		  $tmima=$row['tmima']; 
		  $stnam=$row['stnam'];
		  $bd=$row['Name'];
		  
		  echo "<td>". $plithos . "</td>";
		  echo "<td>". $mitroo . "</td>";
		  echo "<td>". $tmima . "</td>";
		  echo "<td>". $bd. "</td>";
		  echo "<td>". $stnam . "</td>";
		  echo "</tr>";
	}
	echo "</table>"; 
}
else
{
	echo "<br>"."ΔΕΝ ΥΠΑΡΧΟΥΝ ΑΠΟΥΣΙΕΣ";
}	

?>
<br><br><br>
<button onClick="window.print()">ΕΚΤΥΠΩΣΗ ΟΘΟΝΗΣ</button>
<a  href=<?php echo $menu;?> style="color:blue "  > <button> Επιστροφή στο Μενού  </button> </a>
</body>
</html>