<?php
session_start();
if (!(isset($_SESSION['islogin']) && $_SESSION['islogin'] != '')) {
header ("Location: dilosilogin.php");
}
include "logo.php";
$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:11px;"></p>
</style>

</script>
<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=1000, height=300, top='+top+', left='+left);
}

function KeepCount()  { 
    var elements = document.getElementsByName("mathsel[]");
    var total = 0;
    for(var i in elements) {
        var element = elements[i];
        if(element.checked) total++;
        if(total <> 2) {
            alert("Να επιλέξετε 2 μαθήματα");
            element.checked = false;
            return false;    
        }
    }
  } 
  
 
  
</script>

</head>
<body  style="width:995px; margin:0 auto; ">

<?php 
require("dbconnectdilosi.php");

$usr=$_SESSION['usr'];
$tmima=$_SESSION['tmima'];
$onoma=$_SESSION['onoma'];
$taxi=$_SESSION['taxi'];
if ($taxi =='Γ') {
  ?><h2> ΤΑ ΕΞΕΤΑΖΟΜΕΝΑ ΓΙΑ ΤΗΝ Γ΄ ΛΥΚΕΙΟΥ ΘΑ ΔΗΛΩΘΟΥΝ ΣΤΑ Κ.Σ.Α  </h2><?php }
else if ($taxi =='Α') {
	 ?><h2> ΤΑ ΕΞΕΤΑΖΟΜΕΝΑ ΓΙΑ ΤΗΝ Α΄ ΛΥΚΕΙΟΥ ΕΙΝΑΙ ΚΑΘΟΡΙΣΜΕΝΑ  </h2>
	 <h2> ΝΕΑ ΕΛΛΗΝΙΚΑ, ΜΑΘΗΜΑΤΙΚΑ,ΙΣΤΟΡΙΑ, ΦΥΣΙΟΓΝΩΣΤΙΚΑ(ΦΥΣΙΚΗ,ΧΗΜΕΙΑ,ΒΙΟΛΟΓΙΑ)  </h2>
	 <?php
}
else
{
$sql=  mysqli_query($con,"SELECT  * FROM oldepiloges WHERE mitroo='$usr'");
$row=mysqli_fetch_array($sql);
$sql1= mysqli_query($con,"SELECT  exam2,exam3,exam4 FROM dilosimath WHERE mitroo='$usr'");
$c=mysqli_num_rows($sql1);
if ($c == 0 ) { 
  ?><h2> ΘΑ ΚΑΝΕΤΕ ΑΛΛΑΓΗ ΣΤΑ ΕΞΕΤΑΖΟΜΕΝΑ ΜΑΘΗΜΑΤΑ  </h2><?php
}
else
{
?><h2>ΕΠΙΛΟΓΗ ΕΞΕΤΑΖΟΜΕΝΩΝ ΜΑΘΗΜΑΤΩΝ </h2><?php
}
  $mth[1]=$row['kat1'];
  $mth[2]=$row['kat2'];
  $mth[3]=$row['kat3'];
  $mth[4]=$row['kat4'];
  
  $mathexe1="ΝΕΑ ΕΛΛΗΝΙΚΑ";
  if (in_array("ΜΑΘ_κατ (Β)",$mth))
  {
	  $mathexe2="ΜΑΘ_κατ (Β)";
	  $mth=array_diff($mth, array("ΜΑΘ_κατ (Β)"));
  } 
  else 
  {$mathexe2="ΜΑΘ_κ.κ (Β)";}
?>
<form  name='xx' method='post' action="formaexe.php">
<fieldset style="width:378px"; >
<legend style="color:blue"> ΥΠΟΧΡΕΩΤΙΚΑ ΕΞΕΤΑΖΟΜΕΝΑ </legend><br>
<?php		  
echo $mathexe1."<br>";
echo $mathexe2."<br>";
?>
</fieldset> 
<br>
<h3>ΜΑΘΗΜΑΤΑ ΚΑΤΕΥΘΥΝΣΗΣ - <b>Επέλεξε 2 μαθήματα!</b></h3>
<div style="overflow:scroll; border:1px solid black;width:400px; height: 150px">
<?php
$c=0;	
foreach ($mth as $m) {
if ($m <> NULL ) {$c++;}
}

if ($c==2)
{	
foreach ($mth as $m) {
 if ($m <> NULL ) { 
  echo "<br>"."<input type='checkbox' value='$m' name='mathsel[]' onClick='return KeepCount()' checked >" .$m;}
}
}
else
{
foreach ($mth as $m) {
 if ($m <> NULL ) { 
  echo "<br>"."<input type='checkbox' value='$m' name='mathsel[]' onClick='return KeepCount()'  >" .$m;}
}	
}
?>
</div>
<input type="hidden" name="mathexe1a" value=<?php echo $mathexe1;?> >
<input type="hidden" name="mathexe2a" value=<?php echo $mathexe2;?> >
<br>
<input type="submit" name="submit1" value="Επιλογή Μαθημάτων " >
</form>

<?php
}
?>	
<br /><br />
<a  href=<?php echo $menu;?> style="background-color: #819FF7;font-weight: bold; color: #ffffff;padding:4px;text-decoration:none" >  Επιστροφή στο Μενού  </a>

</body>
</html>