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

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
table.myTable { border-collapse:collapse; }
table.myTable td, table.myTable th { border:1px solid black;padding:2px;font-size:11pt; }
<p style="font-size:11px;"></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, 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);
}
</script>




</head>
<body>
<h3>ΚΑΤΑΛΟΓΟΣ ΜΑΘΗΤΩΝ/ΤΡΙΩΝ ΜΕ ΔΡΑΣΤΗΡΙΟΤΗΤΕΣ</h3>

<?php 
require("dbconnect.php");
$dt=$_SESSION['dt'];
$usr=$_SESSION['usr'];
$access=$_SESSION['access'];
$_SESSION['link1']="ddkteacher.php";
if ($access == 4)
{
  $sql = $dbcon->prepare("SELECT ek.pmp,e.*,e.onoma as drast,a.eponimo,a.onoma,a.tmima,d.mark from ekdilosistu as ek, ekdilosi as e, allstudentinfo as a, ddkportfolio as d  
       where e.katddk>0 and ek.code=e.code and ek.pmp = a.mitroo and e.katddk=d.aa  order by ek.pmp,e.katddk");
   $sql->execute();
}
else
{	
  $sql = $dbcon->prepare("SELECT ek.pmp,e.*,e.onoma as drast,a.eponimo,a.onoma,a.tmima,d.mark from ekdilosistu as ek, ekdilosi as e, allstudentinfo as a, ddkportfolio as d 
       where e.katddk>0 and e.teacher=? and ek.code=e.code and ek.pmp = a.mitroo and e.katddk=d.aa  order by ek.pmp,e.katddk");
  $sql->execute([$usr]);
}	   
$c=$sql->rowCount();
if ($c > 0)
{
echo "<table class='myTable' >
<tr style='border:1px solid black' bgcolor='#d6ff73'  >
<th>ΑΑ</th>
<th>ΜΗΤΡΩΟ</th>
<th>ΤΜΗΜΑ</th>
<th>ΜΑΘΗΤΗΣ / ΤΡΙΑ</th>
<th>ΠΕΡΙΓΡΑΦΗ ΔΡΑΣΗΣ</th>
<th>ΚΩΔ. ΔΔΚ</th>
<th>ΠΕΡΙΟΔΟΙ</th>
<th>ΜΟΝΑΔΕΣ</th>
</tr>";
$row=$sql->fetch(PDO::FETCH_ASSOC);
$i=1;$k=1;
while(!empty($row))
{
	$mitroo[$k]=$row['pmp'];
	$tmima=$row['tmima'];
	$name[$k]=$row['eponimo']." ".$row['onoma'];
	echo "<tr>";
    echo "<td>".$i."</td>";
	echo "<td>".$mitroo[$i]."</td>";
	echo "<td>".$tmima."</td>";
	?>
    <td>
    <a href='ddkbathmos.php?mitr=<?php echo $mitroo[$k]; ?>')"><?php echo $name[$k]; ?></a>
    </td>
    <?php
	$in=0;
	while ($mitroo[$k]==$row['pmp'])
	{
       $drast=$row['drast'];
	   $katddk=$row['katddk'];
	   $mark=$row['mark'];
	   $per=$row['permexri']-$row['perapo']+1;
	   if ($in > 0)
	   {
		   echo "<tr>";
           echo "<td>".$i."</td>";
	       echo "<td>"." "."</td>";
	       echo "<td>"." "."</td>"; 
           echo "<td>"." "."</td>";		   
	   }
       echo "<td>".$drast."</td>";
	   echo "<td>".$katddk."</td>";
	   echo "<td>".$per."</td>";
	   echo "<td>".$mark."</td>";
       echo "</tr>";
       $i++;$in=1;
       $row=$sql->fetch(PDO::FETCH_ASSOC);
    }
	$k++;
}
echo "</table>";	 
}
else
{
	echo "ΔΕΝ ΕΧΕΤΕ ΔΗΛΩΣΕΙ ΔΡΑΣΤΗΡΙΟΤΗΤΕΣ";
}

?>

<br /><br />
<a  href=<?php echo $menu;?> style="color:blue "  > <button> Επιστροφή στο Μενού  </a>
</body>
</html>