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

?>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js">
</script>
<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:2px;font-size:10pt; }
</style>
</script>

</head>

<body>
<h3> ΒΑΘΜΟΙ ΤΜΗΜΑΤΟΣ </h3>

<?php
require "dbconnect.php"; 

//$sql = $dbcon->prepare("SELECT DISTINCT mathima FROM bthis where exetasi > 0 ORDER BY mathima ASC");
$sql = $dbcon->prepare("SELECT DISTINCT mathima FROM bprev where exetasi > 0 ORDER BY mathima ASC");
$sql->execute();  
?>
<form  method='post'> 
  <label>Επέλεξε Εξεταζόμενο Μάθημα:</label>
  <select name='mathid' >
  <?php
  echo "<option value='---'>select</option>";
  while($row=$sql->fetch(PDO::FETCH_ASSOC) ) {
          echo "<option value='$row[mathima]'>$row[mathima]</option>";
      }
      ?>
 </select>
<input type="submit" name="submit1" value="Επιβεβαίωση Επιλογής" >
</form>
<?php
if (isset($_POST['submit1']))
{
	$math=rtrim(ltrim($_POST['mathid']));

$sql = $dbcon->prepare("select b.*, al.eponimo,al.onoma,al.tmima FROM bthis as b,allstudentinfo as al,bprev as l
          where b.mitroo=al.mitroo and b.mathima='$math' and al.tmima like 'Α%' order by al.tmima,al.eponimo,al.onoma ");
$sql->execute(); 
echo '<p style="color: blue; text-align: left; font-weight: bold;"> ΑΝΑΛΥΤΙΚΗ ΒΑΘΜΟΛΟΓΙΑ ΤΜΗΜΑΤΟΣ  </p>';

echo "ΜΑΘΗΜΑ:".$math."<br>";
echo "<table class='myTable' >
<tr style='border:1px solid black' bgcolor='#d6ff73'  >
<th>No.</th>
<th>A/M</th>
<th>ΤΜΗΜΑ</th>
<th>ΜΑΘΗΤΗΣ/ΤΡΙΑ</th>
<th>A ΤΕΤΡ</th>
<th>B ΤΕΤΡ</th>
<th>ΕΧΕΤΑΣΗ</th>
<th>ΜΟ ΤΕΤΡ</th>
<th> </th>
<th>A ΤΕΤΡ Π</th>
<th>B ΤΕΤΡ Π</th>
<th>ΕΧΕΤΑΣΗ Π</th>
<th>ΜΟ ΤΕΤΡ Π</th>
<th> </th>
<th>ΔΙΑΦΟΡΑ ΤΕΤΡ</th>
<th>ΔΙΑΦΟΡΑ ΕΧΕΤ</th>
<th>ΒΑΘΜΟΣ</th>
<th>ΒΑΘΜΟΣ Π</th>
";

$i=1;
$ns=0;
while($row=$sql->fetch(PDO::FETCH_ASSOC) )
{
 $mitr=$row['mitroo'];
 $tmima=$row['tmima'];
 $name=$row['eponimo']." ".$row['onoma'];;
 $b1=$row['bathmosa']; 
 $b2=$row['bathmosb'];
 $ex=$row['exetasi'];	
 $mot=($b2+$b1)/2;
 
 //$l1=$row['bal']; 
 //$l2=$row['bbl'];
 //$exl=$row['bxl'];	
 //$motl=($l2+$l1)/2;
 
 //$dif1=$mot-$motl;
 ///$dif2=$ex-$exl;
 $bathmos=(($mot*70)+($ex*30))/100;
 //$bathmosl=(($motl*70)+($exl*30))/100;	
  echo "<tr>";
  echo "<td>". $i;
  echo "<td>". $mitr . "</td>";
  echo "<td>". $tmima . "</td>";
  echo "<td >". $name . "</td>";
  echo "<td >". $b1 . "</td>";
  echo "<td >". $b2 . "</td>";
  echo "<td bgcolor='#6FFAaC'>"."<p align=right>".$ex."</td>";
  echo "<td >". $mot . "</td>";
  echo "<td >". " " . "</td>";
  echo "<td >". $l1 . "</td>";
  echo "<td >". $l2 . "</td>";
  echo "<td bgcolor='#6FFAaC'>"."<p align=right>".$exl."</td>";
  echo "<td >". $motl . "</td>";
  echo "<td >". " " . "</td>";
  if (abs($dif1) >=0 and abs($dif1) <=3)
   
	{
	   echo "<td>"."<p align=right>".$dif1."</td>";
	}
	else if (abs($dif1) >= 4)
	{
		echo "<td bgcolor='#6FFA0C'>"."<p align=right>".$dif1."</td>";
	}
	else
    {
	echo "<td bgcolor='#FF0000'>"."<p align=right>".$dif1."</td>";
    }
	
  if (abs($dif2) >=0 and abs($dif2) <=3)
   
	{
	   echo "<td>"."<p align=right>".$dif2."</td>";
	}
	    else if (abs($dif2) >= 4)
	{
		echo "<td bgcolor='#6FFA0C'>"."<p align=right>".$dif2."</td>";
	}
	else
    {
	echo "<td bgcolor='#FF0000'>"."<p align=right>".$dif2."</td>";
    }
	echo "<td >". $bathmos . "</td>";
	echo "<td >". $bathmosl . "</td>";
	echo "</tr>";
	if ($ex > 0)
	{
    $tot1=$tot1+$mot;
	$tot2=$tot2+$ex;
	$tot3=$tot3+$motl;
	$tot4=$tot4+$exl;
	$ns++;
	}
	$i++;
}
if($ns > 0)
{
  $mo1=$tot1/$ns;
  $mo2=$tot2/$ns;
  $mo3=$tot3/$ns;
  $mo4=$tot4/$ns;
}
echo "</table>";  
  echo "ΜΕΣΟΣ ΤΕΤΡΑΜΗΝΩΝ : ".number_format($mo1,2)."<br>";
   echo "ΜΕΣΟΣ ΟΡΟΣ ΕΞΕΤΑΣΗΣ : ".number_format($mo2,2)."<br>";
   echo "ΜΕΣΟΣ ΤΕΤΡΑΜΗΝΩΝ Π: ".number_format($mo3,2)."<br>";
   echo "ΜΕΣΟΣ ΟΡΟΣ ΕΞΕΤΑΣΗΣ Π: ".number_format($mo4,2)."<br>";
}




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

</body>
</html>