<?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 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=700, height=600, top='+top+', left='+left);
}
</script>
</head>

<body>

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


$sql = $dbcon->prepare("select Class_id from voithos where yt=? ");
$sql->execute([$usr]);
if ($sql->rowCount()>0)
{
    $row=$sql->fetch(PDO::FETCH_ASSOC);
    $tmimaid=$row['Class_id'];
	include "maketimorep.php";	

?>
<h3> ΠΛΗΡΟΦΟΡΗΣΗ ΓΙΑ ΤΟ ΤΜΗΜΑ: <?php echo $tmimaid; ?> </h3>
<?php
echo "<table class='myTable' >
<tr style='border:1px solid black' bgcolor='#d6ff73'  >
<th>A/A</th>
<th>ΜΗΤΡ</th>
<th>ΜΑΘΗΤΗΣ / ΤΡΙΑ</th>
<th>ΑΠΟΥΣ</th>
<th>ΚΑΘΣΕΙΣ</th>
<th>ΑΝΑΣΤΟΛΗ</th>
<th>ΚΑΤΟΙΚΟΝ</th>
<th>ΣΤΗΡΙΞΗ</th>
<th>ΑΠΑΛΛΑΓΕΣ</th>
<th>ΔΙΕΥΚ.</th>
<th>ΑΝΑΜΕΝ. ΕΠΙΔΟΣΗ</th>
<th>ΠΡΟΦΙΛ</th>
</tr>";
	
$sql1 = mysqli_query($con,"SELECT mitroo,onoma,eponimo FROM allstudentinfo WHERE tmima='$tmimaid' ORDER by eponimo,onoma " );
$k=1;
while ($rowall = mysqli_fetch_array($sql1))
{
  $mitr=$rowall['mitroo'];
  echo "<td>".$k. "</td>"; 
  echo "<td>";
  ?>
  <a href="#" onClick="popupCenter('kartelan.php?data=<?php echo $mitr; ?>')"><?php echo $mitr; ?></a> 
  <?php
  echo "</td>";
  echo "<td>".$rowall['eponimo']." ".$rowall['onoma']."</td>"; 
  
  $sql = mysqli_query($con,"SELECT count(period) as apou FROM apousies WHERE mitroo='$mitr' AND apousia=1  ORDER BY dateout,period " );
  $row = mysqli_fetch_array($sql);
  echo "<td>".$row['apou']. "</td>"; 
  
  $sql= mysqli_query($con,"SELECT count(period) as kathi FROM apousies WHERE mitroo='$mitr' AND apousia=0 AND kath > 0  ORDER BY dateout,period " );	
  $row = mysqli_fetch_array($sql);
  echo "<td>".$row['kathi']. "</td>";
  
  $sql=mysqli_query($con,"select 1 from timoreport"); 
  $c1=mysqli_num_rows($sql);
  if ($c1 > 0) 
  {
  $sql=mysqli_query($con,"SELECT SUM(timo) as cana FROM timoreport WHERE mitroo='$mitr' and eidostimo=0 " );
  $row = mysqli_fetch_array($sql);
  echo "<td>".$row['cana']. "</td>";
  $sql=mysqli_query($con,"SELECT SUM(timo) as ckat FROM timoreport WHERE mitroo='$mitr' and eidostimo=1 " );
  $row = mysqli_fetch_array($sql);
  echo "<td>".$row['ckat']. "</td>";
  }
  else
  {
	echo "<td>"." ". "</td>";  
	echo "<td>"." ". "</td>"; 
  }
  ////////////
  $flag=0;
  $sql = mysqli_query($con,"SELECT * FROM problimata WHERE mitroo='$mitr'  " );
  $c=mysqli_num_rows($sql);
  $dfx="";
  if ($c > 0)
  {
			$row = mysqli_fetch_array($sql);
		    $problima=$row['problima'];
			$aporos=$row['aporos'];
			$flag=1;
			
			for ($k=1;$k<=6;$k++)
			{
			  $x='dief'.$k;
			  if ($row["$x"]<>0){$dfx=$dfx.$row["$x"].",";} 
			}
			$dfx=trim($dfx,',');
		}
		$diefk=$dfx;
		
		$sql = mysqli_query($con,"SELECT * FROM apallagesm WHERE mitroo='$mitr'  " );
        $c=mysqli_num_rows($sql);
		$apal="";
        if ($c > 0)
        {
			
			
			while($row=mysqli_fetch_array($sql))
			{
			   $apal=$apal.$row['mathima'].",";
			   
			}
			
        }
		$sql = mysqli_query($con,"SELECT * FROM stiriksim WHERE mitroo='$mitr'  " );
        $c=mysqli_num_rows($sql);
		$st='';
        if ($c <> 0)
        {
			$flag=1;
			$i=1;
			while($row=mysqli_fetch_array($sql))
			{
				$stir[$i]=$row['mathima'];
				$pers[$i]=$row['per'];
				$st=$st.$stir[$i]."(".$pers[$i].")".",";
				$i++;
			}
			$str=trim($st,',');
		}
		
		$cr++;
	
	 echo "<td>".trim($st,',')."</td>";
	 echo "<td>".trim($apal,',')."</td>";
	 echo "<td>".$diefk."</td>";
	 
  /////////////
  echo "</tr>";
  $k++;  
}
	 
echo "</table>";
$df=array('','Επιπρόσθετος χρόνος','Ορθογραφία/Σύνταξη','Απλοποίηση δοκιμίου','Μεταγραφέας','Έμφαση στα Προφορικά','Μικρά διαλείμματα');
echo "<br>"."<br>";
echo "<table class='myTable' >
<tr style='border:1px solid black;font-size:14px'  >
<th>ΚΩΔΙΚΟΣ</th>
<th>ΔΙΕΥΚΟΛΥΝΣΗ</th>
</tr>";
for ($i=1;$i<=6;$i++)
{
	 echo "<tr>";
	 echo "<td>" .$i. "</td>";;
	 echo "<td>". $df[$i]. "</td>";
	 echo "</tr>";
}
echo "</table>";	
}
else
{
	echo "ΔΕΝ ΕΧΕΤΕ ΥΠΕΥΘΥΝΟΤΗΤΑ ΤΜΗΜΑΤΟΣ";
}
//<a  href="apmath.php" style="color:blue "  > <button> Επανάληψη Αναφοράς  </a>
 ?>
<br /><br />

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