<?php
include "scrinit.php";
include $menu;
?>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="style1.css" rel="stylesheet" type="text/css" />

<script type="text/javascript" src="https://code.jquery.com/jquery-1.9.1.min.js"></script>
<script type="text/javascript">
$(function() {
 $("#mathsubid").bind("change", function() {
     $.ajax({
         url: "change1.php",
         data: "mathsubid="+$("#mathsubid").val(),
         success: function(html) {
             $("#codeid").html(html);
         }
     });
 }); 
});

function deleterow(code)
{
        var xhttp = new XMLHttpRequest();
		xhttp.onreadystatechange = function() 
		{                     
			
			if (this.readyState == 4 && this.status == 200) {
                   alert("Η αξιολόγηση διαγράφηκε!");
            }
        };
		var txt;
        var r = confirm("Να Διαγραφεί αυτή η Αξιολόγηση;");
        if (r == true) 
		{
            var td = event.target.parentNode; 
            var tr = td.parentNode; // the row to be removed
			tr.parentNode.removeChild(tr);
			xhttp.open("POST", "deleteaks.php", true);
			xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
			xhttp.send("id="+code);
        } 
		
}       
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=900, height=300, top='+top+', left='+left);
}

function pop_up(url)
{
window.open(url,'win2','status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=700,height=500,directories=no,location=no') 
}
</script>

</head>

<body>

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

echo "<p class='p1'>". "ΚΑΤΑΧΩΡΗΣΗ/ΔΙΟΡΘΩΣΗ ΒΑΘΜΟΛΟΓΙΑΣ". "</p>";
echo "<p class='p2'>". "ΔΗΛΩΜΕΝΕΣ ΑΞΙΟΛΟΓΗΣΕΙΣ ΓΙΑ ΟΛΑ ΤΑ ΜΑΘΗΜΑΤΑ". "</p>";
$q=mysqli_query($con,"select * from declarations where teacher='$usr' order by tetramino,class,testdate");
$c=mysqli_num_rows($q);
echo "<table class='myTable3' >
<tr> 
<th>α/α</th>
<th>Ημερομηνία Διαγ</th>
<th>Τετράμηνο</th>
<th>Τμήμα/Συνδιδ</th>
<th>Μάθημα</th>
<th>Θέμα διαγ</th>
<th>Χρόνος</th>
<th>Καταχώρηση Βαθμολογίας</th>
<th>Χρωστουν Αξιολόγηση</th>
<th>Στατιστικά</th>
<th>Διαγραφή</th>
</tr>";
$i=1;
if ($c==0)
{
	echo "<p class='p2'>". "ΔΕΝ ΥΠΑΡΧΟΥΝ ΔΗΛΩΜΕΝΕΣ ΑΞΙΟΛΟΓΗΣΕΙΣ". "</p>";
}
else
{
	while($row=mysqli_fetch_array($q))
	{
		echo "<tr>";
		echo "<td>". $i."</td>";
		
		echo "<td>". $row['testdate']."</td>";
		echo "<td>". $row['tetramino']."</td>";
		echo "<td>". $row['class']."</td>";
		echo "<td>". $row['subject']."</td>";
		echo "<td>". $row['thema']."</td>";
		echo "<td>". $row['duration']."</td>";
		$code=$row['code'];
		$dis='';
		/*if ($dt < $row['testdate'])
		{
			
			echo "<td>" . "". "</td>";
			echo "<td>" . "". "</td>";
			echo "<td>" . "". "</td>";
			echo "<td>" . "". "</td>";
		}
		else
		{*/
			if ($code==0)
			{
				$cd="Καταχώρηση";
				$code=$code.'/'.$row['testdate'].'/'.$row['class'].'/'.trim($row['subject']).'/'.$row['id'].'/'.$row['duration'];
				echo "<td>" . "<a href=\"bathmo11.php?data=".$code."\">"."<b>".$cd."</b>". "</a>". "</td>";
			?><td></td><td></td><td></td><?php
						
			}
			else
			{
				$cd='Διόρθωση';
				echo "<td>" . "<a href=\"bathmo11.php?data=".$code."\">"."<b>".$cd."</b>". "</a>". "</td>";
				?><td>
				<a href="noexam.php?data=<?php echo $code; ?>" onclick="pop_up(this);  return false;" onfocus="this.blur();">Χρωστούν Διαγώνισμα</a>
				</td><td>
				<a href="bathmostat.php?data=<?php echo $code; ?>" onclick="pop_up(this);  return false;" onfocus="this.blur();">Στατιστικό</a>
				</td><?php
				echo '<td><button onclick="deleterow('.$code.')" style="color: #cc0000">Διαγραφή</button></td>';
			}
			
			
		//}
		echo "</tr>";
		$i++;
	}
	echo "<table>";
}


?>
</body>
</html>