<?php
include "scrinit.php";
include "logo.php";
?>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="style1.css" rel="stylesheet" type="text/css" />
<style type="text/css">
input.right{  text-align:right;  }
table.myTable { border-collapse:collapse; }
table.myTable td, table.myTable th { border:1px solid black;padding:1px;font-size:12pt; }
.fieldset
{
    width:900px;
	background: #F5F9F0;
	border:2px solid green;
    -moz-border-radius:4px;
    -webkit-border-radius:4px;	
    border-radius:4px;	
}
</style>

</head>
  
<body>
<p class='p1'>ΚΑΤΑΣΤΑΣΗ ΒΑΘΜΟΛΟΓΙΑΣ ΤΕΤΡΑΜΗΝΟΥ</p>
<?php
require "dbconnect.php"; 
$dt=$_SESSION['dt'];
$teacher=$_SESSION['usr'];
$tetramino=$_SESSION['tetramino'];
$name=$_SESSION['n'];
//////////////// get data //////////////
$code=$_GET['code'];
$q1=mysqli_query($con, "select * from bathmoposo WHERE id='$code'");
$row=mysqli_fetch_array($q1);
$mathima=$row['mathima'];
$tmima=$row['tmima'];

$q=mysqli_query($con,"select * from kodikoimathimatos where kodikos='$mathima'");
$row=mysqli_fetch_array($q);
$ekset=$row['ekset'];
$p1=$row['pgrapto'];
$p2=$row['pproforiko'];
$cl=mb_substr($tmima,0,1,'UTF-8');

echo "ΔΙΔΑΣΚΩΝ: ". $name."<br>";
echo "ΜΑΘΗΜΑ / ΣΥΝΔΙΔΑΣΚΑΛΙΑ: ".$tmima." / ".$mathima;

$result = mysqli_query($con,"SELECT DISTINCT s.mitroo,a.eponimo,a.onoma,a.tmima 
FROM syndidaskalies as s,allstudentinfo as a, syndcodes as sc 
WHERE sc.synd = '$tmima' AND s.mitroo=a.mitroo AND sc.syndid=s.syndid ORDER BY a.eponimo,a.onoma");
$crow1=mysqli_num_rows($result);

if ($crow1 > 0)
{
	$cr=0;
	while($row=mysqli_fetch_array($result))
	{	
		$cr++;
		$mt[$cr]=$row['mitroo'];
	    $epo[$cr]=$row['eponimo']." ".$row['onoma'];	
		$tmim[$cr]=$row['tmima'];
	}
}
else
{	
$result = mysqli_query($con,"SELECT mitroo,eponimo,onoma FROM allstudentinfo WHERE tmima='$tmima' ORDER BY eponimo,onoma  ");
$crow1=mysqli_num_rows($result);
    $cr=0;
    while($row = mysqli_fetch_array($result))
     {
	 $cr++;
	 $mt[$cr]=$row['mitroo'];
	 $epo[$cr]=$row['eponimo']." ".$row['onoma'];
	 $tmim[$cr]=$tmima;
	 } 
}
// number of students
$ns=$cr;	

$sql=mysqli_query($con,"SELECT mitroo,bgrapto,bproforiko FROM bathmostetr 
		WHERE code='$code'");
$i=0;
$omp='';
include "pososta.php";
while($row=mysqli_fetch_array($sql))
{
	   $i++;
	   $m=$row['mitroo'];
	   $r = mysqli_query($con,"select omp FROM allstudentinfo where mitroo='$m' ");	
	   $row1=mysqli_fetch_array($r);
	   $omp=trim($row1['omp']);
	   include "pososta.php";
	   $gr[$m]=$row['bgrapto'];
	   $pr[$m]=$row['bproforiko'];
}

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>
</tr>
<tr><th colspan='4'><th>".$p1."%"."</th><th>".$p2."%"."</th><th></th>";
$i=1;
while($i <=$ns){
  echo "<tr>";
  echo "<td>" .$i;
  echo "<td>". $mt[$i] . "</td>";
  $m=$mt[$i];
  echo "<td>". $tmim[$i] . "</td>";
  echo "<td>". $epo[$i] . "</td>";
  echo "<td style='text-align:right'><b>".$gr[$m]."</b></td>"; 
  echo "<td style='text-align:right'><b>".$pr[$m]."</b></td>";
  $t=$gr[$m]*$p1/100+$pr[$m]*$p2/100;
  $telikos=round($t);
  echo "<td style='text-align:right'><b>".$telikos."</b></td>";
  echo "</tr>";
  $i++;
}
echo "</table>";
echo "<br>";echo "<br>";
echo "O/Η ΔΙΔΑΣΚΩΝ/ΟΥΣΑ"."<br><br><br>";
echo ".........................."."<br>";
echo $name."<br>";

?>
</body>
</html>
