<?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 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 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);
        } 
		
}       
</script>

</head>

<body>

<?php
require "dbconnect.php"; 
$dt=$_SESSION['dt'];
$name = $_SESSION['n'];
$teacher=$_SESSION['usr'];
$access=$_SESSION['access'];
echo "<p class='p1'>". "ΚΑΤΑΧΩΡΗΣΗ/ΔΙΟΡΘΩΣΗ ΒΑΘΜΟΛΟΓΙΑΣ ΓΙΑ ΜΗ ΔΗΛΩΜΕΝΗ ΑΞΙΟΛΟΓΗΣΗ". "</p>";

$cd=$_GET['mathid'];
if (!empty($cd))
{
    $cc=explode("/",$_GET['mathid']);
	$tm1=$cc[0]."/".$cc[1];
	$tmima=$cc[0];
	$subject=$cc[1];
}	

//$_SERVER['PHP_SELF'];

$sqlx=mysqli_query($con,"select type,code from aksiologiseis where subject='ΟΛΑ' and id > 5 ");

$sql1=mysqli_query($con,"select * from aksinfo where subject='$subject' and tmima='$tmima' and pmpteacher='$teacher' and declaid=0 ");
if (mysqli_num_rows($sql1)>0)
{
	echo "<p class='p1'>". "ΚΑΤΑΧΩΡΙΣΜΕΝΕΣ ΜΗ ΔΗΛΩΜΕΝΕΣ ΑΞΙΟΛΟΓΗΣΕΙΣ". "</p>";
    echo "<table class='myTable3' id='tablex' >
	<tr> 
	<th>α/α</th>
	<th>Κωδικός</th>
	<th>Ημερομηνία</th>
	<th>Τετράμηνο</th>
	<th>Τμήμα/Συνδιδ</th>
	<th>Μάθημα</th>
	<th>Τύπος Αξιολόγησης</th>
	<th>Διόρθωση</th>
	<th>Διαγραφή</th>
	</tr>";
	$cdnea="Καταχώρηση βαθμολογίας για νέα μη δηλωμένη αξιολόγηση";
	$codenea=0;
	$i=1;
	while($row=mysqli_fetch_array($sql1))
		{
			echo "<tr>";
			echo "<td>". $i."</td>";
			echo "<td>". $row['code']."</td>";
			echo "<td>". $row['dateaks']."</td>";
			echo "<td>". $row['tetramino']."</td>";
			echo "<td>". $row['tmima']."</td>";
			echo "<td>". $row['subject']."</td>";
			echo "<td>". $row['type']."</td>";
			$code=$row['code'];
			$codenea='0'.'/'.$row['tmima'].'/'.trim($row['subject']);
			$cd='Διόρθωση';
			echo "<td>" . "<a href=\"bathmo1.php?data=".$code."\">"."<b>".$cd."</b>". "</a>". "</td>";
			echo '<td><button onclick="deleterow('.$code.')" style="color: #cc0000">Διαγραφή</button></td>'; 
			echo "</tr>";
			$i++;
		}
		echo "<tr>";
		echo "<td>". $i."</td>";
		echo "<td colspan='7'>" . "<a href=\"bathmo1.php?data=".$codenea."\">"."<b>".$cdnea."</b>". "</a>". "</td>";
		echo "</tr>";
		echo "<table>";
}
else
{
	include "bathmo1.php";
}

?>
</body>
</html>