<?php
include "scrinit.php";
include "logo.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:14px; }
<p style="font-size:14px;"></p>
</style>



<h2>ΠΡΟΕΙΔΟΠΟΙΗΜΕΝΑ ΔΙΑΓΩΝΙΣΜΑΤΑ </h2>
<?php
require "dbconnect.php";
$usr=$_SESSION['usr'];
$tetramino=$_SESSION['semester'];

if (isset($_POST['nameid'])) {$mitr=$_POST['nameid'];}
else
$mitr=$_SESSION['studentid'];

$sqldia = mysqli_query($con,"SELECT * FROM declarations WHERE tetramino='$tetramino' order by testdate " );
$n=mysqli_num_rows($sqldia);
$sqltmima=mysqli_query($con,"SELECT tmima FROM allstudentinfo WHERE mitroo='$mitr' " );
$rowtmima = mysqli_fetch_array($sqltmima);
$tmima=$rowtmima['tmima'];

$i=1;
while ($rowdia = mysqli_fetch_array($sqldia))
{
$class=$rowdia['class'];
	
$sql = mysqli_query($con,"SELECT mitroo FROM allstudentinfo WHERE tmima='$class' AND mitroo='$mitr' " );
if (mysqli_num_rows($sql) > 0) 
{
$testsubject[$i] = $rowdia['subject'];
$testdate[$i]=$rowdia['testdate'];
$testclass[$i]=$rowdia['class'];
$testreturn[$i]=$rowdia['returndate'];
$i++;
}
else
{
$sql = mysqli_query($con,"SELECT s.mitroo FROM syndidaskalies as s,syndcodes as c 
	   WHERE c.synd='$class' AND s.mitroo='$mitr' AND s.syndid=c.syndid  " );
if (mysqli_num_rows($sql) > 0) 
{	
$testsubject[$i] = $rowdia['subject'];
$testdate[$i]=$rowdia['testdate'];
$testclass[$i]=$rowdia['class'];
$testreturn[$i]=$rowdia['returndate'];
$i++;
}
else
{
$flag1=mb_substr($class, 0, 1, 'utf-8');

$flag2=mb_substr($class, 1, 1, 'utf-8');
$flag3=$flag1."0".$flag2;

if ($flag3==$tmima) {
 $testsubject[$i] = $rowdia['subject'];
 $testdate[$i]=$rowdia['testdate'];
 $testclass[$i]=$rowdia['class'];
 $testreturn[$i]=$rowdia['returndate'];
 $i++;	
}
}
}
}
$i=$i-1;
$dt2 = date('Y-m-d');
echo "<table style='width:600px' class='myTable' >
<tr style='border:1px solid black' bgcolor='#FFAF80'  >
"."<th>".'Ημερ. Διαγωνίσματος'."</th>"."<th>".'Μάθημα'."<th>".'Τμήμα'."<th>".'Ημερ. Επιστροφής'."</tr>";
for ($j=1;$j<=$i;$j++)
{
     $d=date('d-m-Y', strtotime($testdate[$j]));
     if ($dt2 > $testdate[$j]) 
	 {
	 echo "<td>"."<font color='red'>$d  </font>"  ."</td>";
	 echo "<td>"."<font color='red'> $testsubject[$j] </font>"  ."</td>";
	 echo "<td>"."<font color='red'> $testclass[$j] </font>"  ."</td>";
	 echo "<td>"."<font color='red'> $testreturn[$j] </font>"  ."</td>";
	 echo "</tr>";
	 }
	 else
	 {
	 echo "<td>". $d ."</td>";
	 echo "<td>". $testsubject[$j]  ."</td>";
	 echo "<td>". $testclass[$j]  ."</td>"; 
	 echo "<td>". $testreturn[$j]  ."</td>";  
	 echo "</tr>";
	 }
}
echo "</table>";

?>

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