<?php
include "scrinit.php";

?>
<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'];
$datedisp= date('d-m-Y', strtotime($dt)); 
$yt=0;

$sql = mysqli_query($con,"SELECT Class_id from voithos where yt='$usr'");
if (mysqli_num_rows($sql) > 0)
{
  $row=mysqli_fetch_array($sql);
  $tmima= $row['Class_id'];
  echo "<p>".""."</p>";
  echo '<p style="color: red;font-size: 14pt;">
      ΚΑΤΑΛΟΓΟΣ ΜΑΘΗΤΩΝ ΜΕ ΛΗΓΜΕΝΟ RAPID TEST!
      </p>';

	echo "<table class='myTable' >
     <tr style='border:1px solid black' bgcolor='#FF3352'  >
     <th>A/A</th>
     <th>ΜΗΤΡΩΟ</th>
     <th>ΜΑΘΗΤΗΣ / ΤΡΙΑ</th>
     <th>ΗΜΕΡΟΜΗΝΙΑ ΤΕΣΤ</th>";
  $sql = mysqli_query($con,"SELECT mitroo,eponimo,onoma FROM allstudentinfo where tmima='$tmima' order by eponimo,onoma");
  $i=1;
  while($row=mysqli_fetch_array($sql))
  {
    $mit=$row['mitroo'];
	$sqlr = mysqli_query($con,"SELECT mpoli,covid,testdate from rapidimg where mitroo='$mit' ");
	$rowr=mysqli_fetch_array($sqlr);
	$dcovid=$rowr['covid'];
    $drapid=$rowr['testdate'];
	$mpoli=$rowr['mpoli'];
	$dater = strtotime("+3 day", strtotime($drapid));
	$dat= date('d-m-Y', $dater);
	
	if ($mpoli === '0')
	{
		if( strtotime($dcovid) == strtotime('0000-00-00'))
		{
			if(strtotime($dt) > strtotime($dat) )
				{
					
					$stname=$row['eponimo']." ".$row['onoma'];
			  
					echo "<tr>";
					echo "<td>".$i. "</td>"; 
					echo "<td>".$mit."</td>"; 
					echo "<td>".$stname."</td>";
					echo "<td>".$dat."</td>"; 
					echo "</tr>";
					$i++;  
				}
		}
	}
  }
  echo "</table>";
} 
