<?php
include "scrinit.php";

?>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>entopismos mathiti</title>
</script>
<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=900, height=300, top='+top+', left='+left);
}
</script>
<style type="text/css">
input.right{  text-align:right;  }
table.myTable { border-collapse:collapse; }
table.myTable td, table.myTable th { border:1px solid black;padding:2px;font-size:10pt; }
</style>
</head>

<body>
<?php
require "dbconnect.php";   
    
	 $mitr=$_GET['mitr']; //mitro mathiti
	 $tea1pmp=$_SESSION['usr']; // BD pmp 
	$sql=mysqli_query($con,"SELECT concat(al.eponimo,' ',al.onoma) as name1,
	                               (case when (a.`dateout` >= '2019-01-14') then '2' else '1' end) AS tetramino ,
                          	COUNT(*) as no
                        	FROM  apousies as a,
                                  allstudentinfo as al,
								  voithos v
	                       WHERE al.mitroo = '$mitr' AND
						         al.mitroo = a.mitroo AND
                          	 	 a.kath>5 and
								 al.tmima  =v.class_id  AND
								 v.voi_id = '$tea1pmp'
	                        GROUP BY 1, 2  
                        	having no>10
                        	order by 1 asc, 2 "); 
  
echo "<br>"."<b>"."Μαθητής με συστηματική καθυστέρηση</b>";	
echo "<table class='myTable' >
<tr style='border:1px solid black' bgcolor='#d6ff73'  >
<th>α/α</th>
<th>Ονοματεπώνυμο</th>
<th>Τετράμηνο</th>
<th>Αριθμός καθυστερήσεων</th>
</tr>";
$i=1;
while($row=mysqli_fetch_array($sql))
{
  echo "<tr>";
  echo "<td>" .$i;
  echo "<td>".$row['name1'] . "</td>";
  echo "<td>". $row['tetramino'] . "</td>";
  echo "<td>". $row['no'] . "</td>";
  echo "</tr>";
  $i++;
}
echo "</table>";	
?>
<br><br> 
<input type="button" name="epistrofi" value="Επιστροφή" onClick="self.close()">  
</body>
</html>