<?php
include "scrinit.php";
include "logo.php";

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<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>
<?php
require("dbconnect.php");
if (isset($_POST['Submitdel'])) 
{
	$id=$_POST['id'];
	$ekdilo = $_POST['ekdilo'];
	mysqli_query($con,"delete from offperiods where id='$id'");
	echo "Η ΕΚΔΗΛΩΣΗ "."<b>".$ekdilo."</b>"." ΕΧΕΙ ΔΙΑΓΡΑΦΕΙ!";
}
elseif (isset($_POST['Submitekd'])) 
{ 
$ekdilo = $_POST['ekdilo'];
$perapo = $_POST['perapo'];
$permexri = $_POST['permexri'];
$datefrom = $_POST['datefrom'];
$dateto= $_POST['dateto'];
$flag=$_POST['flag'];
$id=$_POST['id'];
$tmimafrom= $_POST['tmimaf'];
$tmimamexri= $_POST['tmimat'];
//*****************************************
$sql1 = "SELECT * FROM declarations WHERE testdate >='$datefrom' AND testdate <='$dateto'" ;
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 "<br>"."<br>";	
echo " ΥΠΑΡΧΟΥΝ ΔΗΛΩΜΕΝΑ ΔΙΑΓΩΝΙΣΜΑΤΑ";
echo "<br>"."<br>";
echo "<table class='myTable' >
<tr style='border:1px solid black;font-size:9px'  >
<tr>
<th>Α/Α</th>
<th>ΔΙΔΑΣΚΩΝ</th>
<th>ΗΜΕΡ. ΔΗΛΩΣΗΣ</th>
<th>ΗΜΕΡ. ΔΙΑΓΩΝ</th>
<th>ΜΑΘΗΜΑ</th>
<th>ΤΜΗΜΑ/ΣΥΝΔ.</th>
<th>ΠΕΡΙΟΔ.</th>
<th>ΔΙΑΡΚ.</th>
</tr>";	

while ($row = mysqli_fetch_array($res)) 
{
	$id1=$row['id'];
	$teacher=$row['teacher'];
	$perapo1=$row['perapo'];
	$permexri1=$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=".$id1."\">"."<b>".$id1."</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>" . $perapo1.' - '.$permexri1. "</td>";
echo "<td>" . $duration. "</td>";
echo "</tr>"; 
	
	//.............................................
}
echo "</table>";
echo "<br>"."<br>";
}	

if ($flag==0)
{
$sql="INSERT INTO offperiods (description,datefrom,dateto,perapo,permexri,tmimafrom,tmimamexri) VALUES ('$ekdilo','$datefrom','$dateto','$perapo','$permexri','$tmimafrom','$tmimamexri')";
if (!mysqli_query($con,$sql)) {die('Error: ' . mysqli_error($con));         }	
}
else
{
 mysqli_query($con,"UPDATE offperiods SET datefrom='$datefrom',dateto='$dateto',perapo='$perapo',permexri='$permexri',tmimafrom='$tmimafrom',tmimamexri='$tmimamexri' WHERE id='$id' ");
}
echo "<br>"."<br>";
echo '<p style="color: red; "> Η εγγραφή έγινε με επιτυχϊα !   </p>';

}

//*****************************************


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