<?php 
include "scrinit.php";
include $menu;
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Kathisteriseis</title>
<style type="text/css">
table.myTable { border-collapse:collapse; }
table.myTable td, table.myTable th { border:1px solid black;padding:2px;font-size:10pt; }
<p style="font-size:10px;"></p>
</style>

</script>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script type="text/javascript">
$(function() {
 $("#tmimaid").bind("change", function() {
     $.ajax({
         url: "change.php",
         data: "tmimaid="+$("#tmimaid").val(),
         success: function(html) {
             $("#nameid").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, 'win1', 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=800, height=900, top='+top+', left='+left);
}
</script>
</head>
<body>
<?php 

require("dbconnect.php");
$usr=$_SESSION['usr'];
$access=$_SESSION['access'];
$name=$_SESSION['n'];

echo '<p style="color: red;">Για επιβολή ποινής να κάνετε κλικ πάνω στον Αρθμό Μητρώου του μαθητή! </p>';

if ($access <> 4 )
{
   $sql1 = mysqli_query($con,"SELECT v.class_id,v.voi_id,t.Name 
   FROM voithos as v,teachers as t  WHERE  v.voi_id='$usr' AND t.PMP=v.voi_id ORDER BY v.class_id" );
 }
else
{
   $sql1 = mysqli_query($con,"SELECT v.class_id,t.Name 
   FROM voithos as v,teachers as t WHERE t.PMP=v.voi_id  ORDER BY v.class_id  " );
}


while ($row1 = mysqli_fetch_array($sql1)){
$tmima=$row1['class_id'];
$name=$row1['Name'];


$sql = mysqli_query($con,"SELECT ap.*, al.tmima, al.eponimo,al.onoma FROM apousies as ap,allstudentinfo as al  WHERE 
 ap.mitroo=al.mitroo AND (ap.kath > 0 AND (ap.timoriacode is NULL or ap.timoriacode = 0) )
AND al.tmima='$tmima' ORDER BY ap.mitroo,ap.dateout,ap.period" );

$c= mysqli_num_rows($sql);

if ($c!=0){
echo "<p>"."ΤΜΗΜΑ : "."<b>".$tmima."</b>".str_repeat("&nbsp",10)."ΒΔ: ".$name."</p>";

echo "<table  class='myTable' >
<tr style='border:1px solid black' bgcolor='#ffcc00'  >
<th>α/α</th>
<th>Μητρώο</th>
<th>Όνομα</th>
<th>Καθυστ.</th>
<th>Περίοδ.</th>
<th>Ημερομηνία</th>
</tr>";

$i=1;$j=1;
$row = mysqli_fetch_array($sql);
while($i<=$c)
     { 
	 $mt=$row['mitroo'];
	 $epo=$row['eponimo']. "  ".$row['onoma'];
	 echo "<tr>";
	 echo "<td>" .$j;
	 ?>
     <td>
   <a href="#" onClick="popupCenter('timoria1.php?am=<?php echo $mt; ?>')"><?php echo $mt; ?></a>
    </td>
<?php
	 echo "<td>". $epo;
	 $k=1;
 while ($mt==$row['mitroo'] AND !empty($row)){
	 $kath=$row['kath'];
	 $per=$row['period'];
	 $dat=$row['dateout'];
 	if ($k>1) {
     echo "<tr>";
	 echo "<td>"." ";
	 echo "<td>"." ";
	 echo "<td>"." ";
	 }
	 echo "<td>". $kath;
	 echo "<td>". $per;
	 echo "<td>". $dat;
	
	 echo "</tr>";
 $row = mysqli_fetch_array($sql); 
 $i++;$k++;
	 }
$j++;echo  "</tr>";
    }
	}
echo "</table>";	
}

?>


<br /><br />
<a  href='timoria.php' style="color:blue "> <button>Ανάκληση Ποινής</button></a>&nbsp&nbsp 
<a  href=<?php echo $menu;?> style="color:blue "> <button>Επιστροφή στο Μενού</button>   </a>
</body>
</html>