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

if (isset($_GET['pmp'])){$mitr=$_GET['pmp'];}

if (isset($_POST['nameid'])) {$mitr=$_POST['nameid']; }

$sql = mysqli_query($con,"SELECT eponimo,onoma,tmima FROM allstudentinfo WHERE mitroo='$mitr'  " );
$row = mysqli_fetch_array($sql);
$stname=$row['eponimo']." ".$row['onoma'];
$tmima=$row['tmima'];
$_SESSION['tmimaid']=$tmima;

echo " ΚΑΤΑΓΓΕΛΙΕΣ ΓΙΑ ". " "."<b>".$stname."</b>"." "." του τμήματος ".$tmima."<br>"."<br>";

$sql = mysqli_query($con,"SELECT * FROM kataggelia WHERE mitroo='$mitr' AND kataggelon='$usr'  " );
$c=mysqli_num_rows($sql);

if ($c == 0)
{ 
	echo " ΔΕΝ ΕΧΕΙ ΠΡΟΗΓΟΥΜΕΝΕΣ ΚΑΤΑΓΓΕΛΙΕΣ";}
else
{
echo "<table class='myTable' >
<tr style='border:1px solid black;font-size:9px'  >
<tr>
<th>Αρ.</th>
<th>Ημερομ.</th>
<th>Περιγραφή Παραπτώματος</th>
<th>Καταγγελία από:</th>
<th>Βοηθός Διευθ.</th>
<th>Ποινή</th>
<th>Κατάστ.</th>
</tr>";	
while ($row = mysqli_fetch_array($sql)) {
$aranaforas= $row['aranaforas'];	
$vdid=   $row['bd'];
$kataggelon= $row['kataggelon'];
$datekata= $row['datekata'];
$perigrafi=$row['perigrafi'];
$arsimp = $row['arsimperiforas'];
$datetimo = $row['datetimo'];
$eidostimo = $row['eidostimo'];
$periodoi = $row['periodoi'];
$katastasi = $row['katastasi'];
$timcode=$row['timoriacode'];

$sql1=mysqli_query($con,"SELECT Name  FROM teachers  WHERE  PMP='$vdid' " );
$row1 = mysqli_fetch_array($sql1);
$vname = $row1['Name'];

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

$sql3 = mysqli_query($con,"SELECT perigrafi FROM eidostimorias  WHERE  code='$timcode'" );
$row3 = mysqli_fetch_array($sql3);
$eidostimo = $row3['perigrafi'];

$sql4 = mysqli_query($con,"SELECT perigrafi,metro FROM paraptoma  WHERE  code='$arsimp'" );
$row4 = mysqli_fetch_array($sql3);
$perpara = $row4['perigrafi'];
$metro = $row4['metro'];


echo "<tr>";
//echo "<td>" . "<a href=\"paraptoma1kath.php?data=".$aranaforas."\">".$aranaforas. "</a>". "</td>";
echo "<td>" .$aranaforas. "</td>";
echo "<td>". $datekata . "</td>";
echo "<td>". $perigrafi . "</td>";
echo "<td>". $teacher . "</td>";
echo "<td>". $vname . "</td>";
echo "<td>". $periodoi ." "."περ.". "</td>";
if($katastasi==0) echo "<td>". "ΚΑΤΑΧΩΡΗΘΗΚΕ" . "</td>"; 
if($katastasi==1) echo "<td>". "ΕΚΚΡΕΜΕΙ" . "</td>"; 
if($katastasi==2) echo "<td>". "ΟΛΟΚΛΗΡΩΘΗΚΕ" . "</td>"; 
echo "</tr>"; 
}

$query = mysqli_query($con,"SELECT MAX(aranaforas) FROM kataggelia ");
$results = mysqli_fetch_array($query);
$aranaforas = $results['MAX(aranaforas)'] + 1;
$aranaf=$aranaforas;
$_SESSION['aranaf']=$aranaf;
echo "<tr>";
echo "</tr>"; 
echo "</table>";
echo "<br>"."<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'];
}

$query = mysqli_query($con,"SELECT MAX(aranaforas) FROM kataggelia ");
$results = mysqli_fetch_array($query);
$aranaforas = $results['MAX(aranaforas)'] + 1;
$_SESSION['aranaf']=$aranaforas;

$_SESSION['aranaf']=$aranaf;
include "paraptoma1kath.php"; 


?>
</body>
</html>