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

<h3>ΚΑΤΑΣΤΑΣΗ ΔΙΑΓΩΝΙΣΜΑΤΩΝ </h3>
<?php
date_default_timezone_set("Europe/Athens");
require "dbconnect.php";
$usr=$_SESSION['usr'];
$name=$_SESSION['n'];
echo "<br>"."<br>";
$dt=$_SESSION['dt'];

// define variables with the value for each field
$dia=mysqli_query($con,"select testdate from declarations order by testdate DESC");
$row = mysqli_fetch_array($dia);
$dend=$row['testdate'];
if (isset($_POST['dt'])) {
	$date=$_POST['dt'];}

// define the form into a variable
$fhtml = '<form action="" method="post">
Επέλεξε Ημερομηνία από: <input type="date" name="dta" value="'. $dt. '" />
 Mέχρι: <input type="date" name="dtm" value="'.$dend. '" />
 <input type="submit" value="Επιλογή Ημερομηνίας" />
</form>';

echo $fhtml;         // output /display the form
echo "<br>"."<br>";

if (isset($_POST['dta'])) {
	$dta=$_POST['dta'];
	$dtm=$_POST['dtm'];
   echo " ΔΗΛΩΜΕΝΑ ΔΙΑΓΩΝΙΣΜΑΤΑ ΑΠΟ : "."<b>".date('d-m-Y', strtotime($dta))."</b>";	
   echo "ΜΕΧΡΙ : "."<b>".date('d-m-Y', strtotime($dtm))."</b>"."<br>"."<br>";	
$sql1 = "SELECT d.*,t.Name FROM declarations as d, teachers as t 
WHERE (d.testdate >='$dta' AND d.testdate <='$dtm') and (d.teacher='$usr' and d.teacher=t.PMP)" ;
if (!mysqli_query($con,$sql1)) {die('Error: ' . mysqli_error($con));   }
$res=mysqli_query($con,$sql1);
$c=mysqli_num_rows($res);

if ($c==0){echo " ΔΕΝ ΥΠΑΡΧΟΥΝ ΔΗΛΩΜΕΝΑ ΔΙΑΓΩΝΙΣΜΑΤΑ";}
else
{


echo "<table class='myTable' >
<tr style='border:1px solid black;font-size:12px'  >
<tr>
<th>Α/Α</th>
<th>ΔΙΔΑΣΚΩΝ</th>
<th>ΗΜΕΡ. ΔΗΛΩΣΗΣ</th>
<th>ΗΜΕΡ. ΔΙΑΓ.</th>
<th>ΜΑΘΗΜΑ</th>
<th>ΤΜΗΜΑ/ΣΥΝΔ.</th>
<th>ΠΕΡΙΟΔ.</th>
<th>ΔΙΑΡΚ.</th>
</tr>";	

while ($row = mysqli_fetch_array($res)) 
{
	$id=$row['id'];
	$teacher=$row['Name'];
	$perapo=$row['perapo'];
	$permexri=$row['permexri'];
	$decladate=$row['decladate'];
	$testdate=$row['testdate'];
	$subject=$row['subject'];
	$duration=$row['duration'];
	$class=$row['class'];


echo "<tr>";
echo "<td>" .  "<a href=\"diagoedit.php?data=".$id."\">"."<b>".$id."</b>". "</a>". "</td>";
echo "<td>" . $teacher. "</td>";
echo "<td>" . $decladate. "</td>";
echo "<td>" . $testdate. "</td>";
echo "<td>" . $subject. "</td>";
echo "<td>" . $class. "</td>";
echo "<td>" . $perapo.' - '.$permexri. "</td>";
echo "<td>" . $duration. "</td>";
echo "</tr>"; 
	
	//.............................................
}
echo "</table>";
echo "<br>"."<br>";
}
}
echo "<br>"."<br>";

?>
<input type='button' value='Επιστροφή ' onclick='javascript: window.close();' /> 
</body>
</html>
