<?php
include "scrinit.php";
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="style1.css" rel="stylesheet" type="text/css" />
<title>Διαγωνίσματα</title>
<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=800, height=800, top='+top+', left='+left);
}

function submitform()
{
    document.forms["diagonismanew"].submit();
}

function pop_up(url){
window.open(url,'win2','status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=no, width=1000, height=600, directories=no,location=no') 
}

</script>

<div id='cssmenu'> 

     <h4><?php include 'logo.php'?> </h4>
<h4 class="p1">ΔΙΑΧΕΙΡΙΣΗ ΔΙΑΓΩΝΙΣΜΑΤΩΝ</h4>
<ul id="navbar">
<li class='has-sub'><a href='#' onClick="popupCenter('diagoreport1.php')"><span>ΛΙΣΤΑ ΔΙΑΓΩΝ.</span></a>
   </li> 
 
<li class='has-sub'><a href='#' onClick="popupCenter('diagotmima.php')"><span>ΔΙΑΓ. ΤΜΗΜΑΤΟΣ</span></a>
   </li>  

 <li class='has-sub'><a href='#' onClick="popupCenter('diagoreport3.php')"><span>ΟΙ ΔΗΛΩΣΕΙΣ ΜΟΥ</span></a>
   </li>  

 <li class='has-sub'><a href='#' onClick="popupCenter('diagodiorthosi.php')"><span>ΕΠΙΣΤΡΟΦΗ ΔΙΑΓ. </span></a>
   </li> 
      
<li class='has-sub'><a href='#' onClick="popupCenter('diagodel.php')"><span>ΔΙΑΓΡΑΦΗ ΔΙΑΓ.</span></a>
   </li> 
                  
<li class='has-sub'><a href='#'><span><?php echo "Date: ".date('d-m-Y');?> </span></a>
   </li> 
 
</div>
<body>

<?php

require "dbconnect.php"; 
$dt=$_SESSION['dt'];
$name = $_SESSION['n'];
$usr=$_SESSION['usr'];
$access=$_SESSION['access'];
$tetramino=$_SESSION['tetramino'];
$gym=$_SESSION['gym'];

$sql = mysqli_query($con,"SELECT year FROM generalinfo" );
$row = mysqli_fetch_array($sql);
$xronia=$row['year'];
$_SESSION['xronia']=$xronia;

echo "<br>";
echo "<table class='mytable1' >";
echo "<tr>	";
echo "<td>"."Ημερομηνία:"."</td>";
echo "<td>".date('d-m-Y', strtotime($dt))."</td>";
echo "</tr>	";
echo "<tr>	";
echo "<td>"."Σχολική Χρονιά : "."</td>";
echo "<td>".$xronia."</td>";
echo "</tr>	";
echo "<tr>	";
echo "<td>"."Τετράμηνο : "."</td>";
echo "<td>".$tetramino."</td>";
echo "</tr>	";
echo "<tr>	";
echo "<td>"." Εκπαιδευτικός:"."</td>";
echo "<td>".$name."</td>";
echo "</tr>	";
echo "</table>"; 
echo "<p class='p1'>"."ΕΠΙΛΟΓΗ ΤΜΗΜΑΤΟΣ/ΣΥΝΔΙΔΑΣΚΑΛΙΑΣ ΓΙΑ ΔΙΑΓΩΝΙΣΜΑ-ΑΣΚΗΣΗ"."</p>"; 

$day=array(" ","Mon","Tue","Wed","Thu","Fri");
$sql = $dbcon->prepare("SELECT Name FROM teachers WHERE PMP = ? ");

$sql = $dbcon->prepare("SELECT * FROM timetable WHERE pmp=?  " ); 
$sql->execute([$usr]);
$row=$sql->fetch(PDO::FETCH_ASSOC);

for ($i=1;$i<=5;$i++){
  for ($per=1;$per<=$gym;$per++){
  $dayf=$day[$i].$per;
  $m=$row["$dayf"];
  if ($m <> NULL) {
		  $math1[$i][$per]=$m;}
  else {
	  $math1[$i][$per]=" ";}
  }
}



  //...............................................................
echo "<table  class='mytable3' >
<th>Περ.</th>
<th>Δευτερα</th>
<th>Τρίτη</th>
<th>Τετάρτη</th>
<th>Πέμπτη</th>
<th>Παρασκευή</th>
</tr>";
for ($per=1;$per<=$gym;$per++){
	echo "<tr>";
	echo "<td>".$per."</td>";
	for ($k=1;$k<=5;$k++){
		$math=$math1[$k][$per];
		$array[1] = $math;
        $array[2] = $per;
		$array[3] = $day[$k];
        $str = serialize($array);
        $strenc = urlencode($str);

		echo "<td>" . "<a href=\"diagonisma1.php?data=".$strenc."\">".$math. "</a>". "</td>";
		}
		echo "</tr>";
}
echo "</table>";




?>
<br><br><br>
<a  href='<?php echo $menu;?>' ><button  type="button" class="sb1" >Ακύρωση/Επιστροφή</button> </a>
</body>
</html>