<?php 
include "scrinit.php";
include "logo.php";
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<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=1100, height=800, top=100, left=400');
}

function pop_up(url)
{
window.open(url,'win2','status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=1100,height=800,top=100, left=400') 
}
</script>
<style type="text/css">
table.myTable { border-collapse:collapse; }
table.myTable td, table.myTable th { border:1px solid black;padding:2px;font-size:10pt; }

body {margin:20;}

</style>

</head>
<body>
<?php 
require("dbconnect.php");
$usr=$_SESSION['usr'];
$_SESSION['tmkath']=1;
$tmima=$_GET['tmimaid'];

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

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

$c= mysqli_num_rows($sql);

if ($c!=0)
{
echo "<p>"."ΑΔΙΕΚΠΕΡΑΙΩΤΕΣ ΚΑΘΥΣΤΕΡΗΣΕΙΣ ΓΙΑ ΤΟ ΤΜΗΜΑ : "."<b>".$tmima."</b></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>";	
/////// timorimenes kathisteriseis gia to tmima
$sql = mysqli_query($con,"SELECT t.*,a.onoma,a.eponimo,a.tmima  FROM timoria as t,allstudentinfo as a  
         WHERE t.stu_id=a.mitroo AND vd='$usr' " );
$c1=mysqli_num_rows($sql);

if ($c1==0)
{ 
      echo " ΔΕΝ ΥΠΑΡΧΟΥΝ ΤΙΜΩΡΗΜΕΝΕΣ ΚΑΘΥΣΤΕΡΗΣΕΙΣ ΓΙΑ ΤΟ ΤΜΗΜΑ ".$tmima;}
else
{
echo "<p>"."ΤΙΜΩΡΗΜΕΝΕΣ ΚΑΘΥΣΤΕΡΗΣΕΙΣ ΓΙΑ ΤΟ ΤΜΗΜΑ:"."<b>".$tmima."</b></p>";
echo '<p style="color: red;">Για Ανάκληση ποινής και Επανατύπωση Επιστολής και Δελτίου Αποβολής κλικ πάνω στον ΚΩΔΙΚΟ! </p>';
echo "<table class='myTable' >
<tr style='border:1px solid black;font-size:9px' bgcolor='#ffcc00'  >
<th>Κωδικός</th>
<th>Τμήμα</th>
<th>Ημερομ.</th>
<th>Μαθητής/τρια</th>
<th>Ποινή</th>
</tr>";		
while ($row=mysqli_fetch_array($sql))
{
	$mitroo=$row['stu_id'];
	$tmimax=$row['tmima'];
	if ($tmimax==$tmima)
	{
		$student=$row['eponimo']." ".$row['onoma'];
		$tcode= $row['timoriacode'];	
		$datetimo = $row['dateappl'];
		$timo = $row['peramount'];
		echo "<tr>";
		//echo "<td>" . '<a href=\"timoria3.php?data=".$tcode."\">'."<b>".$tcode."</b>". "</a>". "</td>";
		echo "<td>"."<a href=\"timoria3.php?data=".$tcode."\" onclick=\"pop_up(this.href);return false\">"."<b>".$tcode."</b>". "</a>". "</td>";
		echo "<td>". $tmimax. "</td>";
		echo "<td>". $datetimo . "</td>";
		echo "<td>". $student . "</td>";
		echo "<td>". $timo ." "."περ.". "</td>";
		echo "</tr>"; 
		$i++;
	}

}

echo "</table>";
}
//<a  href='timoria.php' style="color:blue "> <button>Ανάκληση Ποινής</button></a>&nbsp&nbsp 
?>
<br /><br />
<input type="button" name="epistrofi" value="Επιστροφή" onClick="self.close()"> 
</html>