<?php
session_start();
$menu=$_SESSION['menu'];
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:11px; }
<p style="font-size:09px;"></p>
</style>
<?php
require "dbconnect.php";
$usr=$_SESSION['usr'];


//..................................................
if ($usr !=9464 ){

$sqlvd = mysqli_query($con,"SELECT voithos.class_id,voithos.voi_id,vd.voi_name FROM voithos,vd  WHERE  voithos.voi_id='$usr' AND vd.voi_id=voithos.voi_id ORDER BY voithos.class_id" );}
else
{
$sqlvd = mysqli_query($con,"SELECT voithos.class_id,vd.voi_name FROM voithos,vd WHERE vd.voi_id=voithos.voi_id  ORDER BY voithos.class_id  " );}

while ($rowvd = mysqli_fetch_array($sqlvd)){
$tmima=$rowvd['class_id'];
$vdname=$rowvd['voi_name'];
//..................................................
if ($usr==9464)
{
$sqlkata = mysqli_query($con,"SELECT * FROM kataggelia ORDER BY tmima,mitroo " );	
}
else
{
$sqlkata = mysqli_query($con,"SELECT * FROM kataggelia WHERE bd='$usr' ORDER BY tmima,mitroo  " );
$c=mysqli_num_rows($sqlkata);
}

if ($c!=0){
echo "<BR>"."ΚΑΤΑΛΟΓΟΣ ΜΑΘΗΤΩΝ/ΤΡΙΩΝ ΜΕ ΚΑΘΥΣΤΕΡΗΣΕΙΣ ΣΤΟ ΤΜΗΜΑ :". " "."<b>".$tmima."</b>";
echo "<br>"."ΒΟΗΘΟΣ ΔΙΕΥΘΥΝΤΗΣ/ΤΡΙΑ  :"." ".$vdname;

while($rowkata=mysqli_fetch_array($sqlkata)){
echo "<table class='myTable' >
<tr style='border:1px solid black;font-size:9px'  >
<tr>
<th>Α/A</th>
<th>Αρ.Kατ</th>
<th>Ονοματεπώνυμο</th>
<th>Ημερομ.</th>
<th>Περιγραφή Παραπτώματος</th>
<th>Καταγγελία από:</th>
<th>Βοηθός Διευθ.</th>
<th>Ποινή</th>
<th>Κατάστ.</th>
</tr>";	

$mitr=$rowkata['mitroo'];
$tmimag=$rowvd['class_id'];
//echo " ΚΑΤΑΓΓΕΛΙΕΣ ΓΙΑ ΤΜΗΜΑ  ".$tmimag."<br>"."<br>";	
$sql2 = mysqli_query($con,"SELECT eponimo,onoma,tmima FROM allstudentinfo WHERE mitroo='$mitr'  " );
$row2 = mysqli_fetch_array($sql2);

//$tmima=$row2['tmima'];

//$i=1;$j=1;
//$row2 = mysqli_fetch_array($sql2);

     { 
	 //$mitr=$row2['mitroo'];
	 $stname=$row2['eponimo']. "  ".$row2['onoma'];
	 echo "<tr>";
//	 echo "<td>" .$j;
$aranaforas= $rowkata['aranaforas'];	
//$vdid=   $row['bd'];
$kataggelon= $rowkata['kataggelon'];
$datekata= $rowkata['datekata'];
$perigrafi=$rowkata['perigrafi'];
$arsimperiforas = $rowkata['arsimperiforas'];
$datetimo = $rowkata['datetimo'];
$eidostimo = $rowkata['eidostimo'];
$periodoi = $rowkata['periodoi'];
$katastasi = $rowkata['katastasi'];

$sqlp=mysqli_query($con,"SELECT voi_name  FROM vd  WHERE  voi_id='$vdid' " );
$rowp = mysqli_fetch_array($sqlp);
$vname = $rowp['voi_name'];

$sqlq = mysqli_query($con,"SELECT Name FROM teachers  WHERE  PMP='$kataggelon'" );
$rowq = mysqli_fetch_array($sqlq);
$teacher = $rowq['Name'];

$sqlr = mysqli_query($con,"SELECT perigrafi FROM eidostimorias  WHERE  areidostimorias='$eidostimo'" );
$rowr = mysqli_fetch_array($sqlr);
$eidostimo = $rowr['perigrafi'];

echo "<tr>";
echo "<td>". $i . "</td>";
echo "<td>" . $aranaforas. "</td>";
echo "<td>". $stname . "</td>"; 
echo "<td>". $datekata . "</td>";
echo "<td>". $perigrafi . "</td>";
echo "<td>". $teacher . "</td>";
echo "<td>". $vname . "</td>";
//echo "<td>". $eidostimo . "</td>";
echo "<td>". $periodoi ." "."περ.". "</td>";
if($katastasi==0) echo "<td>". "ΚΑΤΑΧΩΡΗΘΗΚΕ" . "</td>"; 
if($katastasi==1) echo "<td>". "ΕΚΚΡΕΜΕΙ" . "</td>"; 
if($katastasi==2) echo "<td>". "ΕΝΗΜΕΡΩΣΗ ΜΕ SMS" . "</td>"; 
if($katastasi==3) echo "<td>". "ΑΠΟΔΕΚΤΗ ΑΠΟ ΚΗΔΕΜΟΝΑ" . "</td>"; 
echo "</tr>"; 
}
echo "</table>";
$i++;	
}
 $rowkata = mysqli_fetch_array($sqlkata); 
 
	 }
echo  "</tr>";
    }
	
echo "</table>";	

//.............................
while ($rowkata = mysqli_fetch_array($sqlkata)) {

echo "<br>";	
$result = mysqli_query($con,"SELECT SUM(periodoi) AS per_sum FROM kataggelia WHERE mitroo='$mitr'  "); 
$row = mysqli_fetch_assoc($result); 
echo "ΣΥΝΟΛΟ ΑΠΟΒΟΛΩΝ: ".$row['per_sum'];
$i=1;echo "<br>";
}

?>

<br /><br /><br /><br />

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