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

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

function popupCenter(pageURL, title, w, h) {
    var left = (screen.width / 2)  - (w / 2);
    var top  = (screen.height / 2) - (h / 2);
    var targetWin = window.open(pageURL, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=700, height=600, top='+top+', left='+left);
}
</script>
</head>

<body>

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

$sql=mysqli_query($con,"select Class_id from voithos where yt='$usr'");
if (mysqli_num_rows($sql)>0)
{
	$i=0;
	while($row = mysqli_fetch_array($sql))
	{
		$i++;
		$tmimaid[$i]=$row['Class_id'];
		$tm=$tm." + ".$tmimaid;
	}
	$tm=ltrim($tm,"+");
	?>
	<h3> ΑΠΟΥΣΙΕΣ ΓΙΑ ΤΟ ΤΜΗΜΑ: <?php echo $tm; ?> </h3>
	<?php
	echo "<table class='myTable' >
	<tr style='border:1px solid black' bgcolor='#d6ff73'  >
	<th>A/A</th>
	<th>ΜΗΤΡΩΟ</th>
	<th>ΜΑΘΗΤΗΣ / ΤΡΙΑ</th>";
	for ($i=1;$i<=$gym;$i++)
	{
		$titep="Περ".$i;
		echo "<th>".$titep."</th>";
	}
	echo "<th>ΣΥΝΟΛΟ</th></tr>";
		
	for ($j=1;$j<=$i;$j++)
	{
		$sql1 = mysqli_query($con,"SELECT mitroo,onoma,eponimo FROM allstudentinfo WHERE tmima='$tmimaid[$j]' ORDER by eponimo,onoma " );
		$k=1;
		while ($rowall = mysqli_fetch_array($sql1))
		{
		  $ap=0;
		  $mitr=$rowall['mitroo'];
		  echo "<td>".$k. "</td>"; 
		  echo "<td>";
		  ?>
		  <a href="#" onClick="popupCenter('apousiesm.php?data=<?php echo $mitr; ?>')"><?php echo $mitr; ?></a> 
		  <?php
		  echo "</td>";
		  echo "<td>".$rowall['eponimo']." ".$rowall['onoma']."</td>"; 
		  $sql = mysqli_query($con,"SELECT period FROM apousies WHERE mitroo='$mitr' AND apousia=1  ORDER BY dateout,period " );
		  $row = mysqli_fetch_array($sql);
		  $totap=array();
		  while($row = mysqli_fetch_array($sql)) 
		  {
			  $totap[$row['period']]++;
			  $ap++;
		  }
		  $i=1;    
		  while($i<=7){echo "<td>".$totap[$i]. "</td>";$i++;}
		  echo "<td>".$ap. "</td>"; 
		  echo "</tr>";
		  $k++;  
		}
	}	 
	echo "</table>";	
}
else
{
	echo "ΔΕΝ ΕΧΕΤΕ ΥΠΕΥΘΥΝΟΤΗΤΑ ΤΜΗΜΑΤΟΣ";
}
//<a  href="apmath.php" style="color:blue "  > <button> Επανάληψη Αναφοράς  </a>
 ?>
<br /><br />

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