<?php
session_start();
ob_start();
if ($_SESSION['islogin']=='' ) { 
  echo "ΠΡΕΠΕΙ ΝΑ ΕΓΓΡΑΦΕΙΤΕ ΓΙΑ ΝΑ ΧΡΗΣΙΜΟΠΟΙΗΣΕΤΕ ΤΟ ΣΥΣΤΗΜΑ"."<BR>";
  sleep(3);
  header ("Location: dilosilogin.php");/* Redirect browser */
  exit();
  }
$menu = $_SESSION['menu'];
include "logo.php";
?>

<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:2px solid black;padding:4px;font-size:12pt; }
<p style="font-size:11px;"></p>
</style>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script type="text/javascript">

    function submitform(action)
    {
        document.getElementById('ss').action = action;
        document.getElementById('ss').submit();
    }

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 KeepCount1()  { 
    var elements = document.getElementsByName("math[]");
    var total = 0;

    for(var i in elements) {
        var element = elements[i];
        if(element.checked) total++;
        if(total>1) {
            alert("Να επιλέξετε μόνο 1 μάθημα");
            element.checked = false;
            return false;    
        }
    }
  } 
  
function KeepCount2()  { 
    var elements = document.getElementsByName("math[]");
    var total = 0;
	var gl = document.getElementById("glossa");
	if ( $.inArray('Ξένη Γλώσσα', elements) > -1 ) {
       
       if (gl.options[gl.selectedIndex].value == 'glossa') {
          alert("Πρέπει να επιλέξετε μια Ξένη Γλώσσα");
          return false;
          }
    }
    for(var i in elements) {
        var element = elements[i];
        if(element.checked) total++;
        if(total>2) {
            alert("Να επιλέξετε 2 μαθήματα");
            element.checked = false;
            return false;    
        }
    }
  }


function myFunction() 
{
var elements = document.getElementsByName("math[]");
var div = document.getElementById("el");
var data = div.textContent;
var total = 0;
var gl = document.getElementById("glossa");

for(var i in elements) 
{
        if(elements[i].checked) 
		{
		   el=elements[i].value;
           if(el == "Ξένη Γλώσσα")
           {	      
             if (gl.options[gl.selectedIndex].value == 'gloss') 
			 {
             alert("Πρέπει να επιλέξετε μια Ξένη Γλώσσα");
             return false;
             }
		  }
		}
}    

for(var i in elements) 
{
        var element = elements[i];
        if(element.checked) total++;
}

if( total < data) 
{
   if(data == 2)
   {alert("Πρέπει να επιλέξετε 2 Μαθήματα"); }
   else 
   {alert("Δεν έχετε επιλέξει Μάθημα"); }
   element.checked = false;
   return false;
}
document.forms["form1"].submit();
return false;
}


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

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

$dt2=$_SESSION['dt'];

$mo=$_GET['mo'];
$arr=explode('/',$mo);
$usr=$arr[0];
$_SESSION['usr']=$usr;
$omp=$arr[1];
$name=$arr[2];
$_SESSION['omp']=$omp;
echo "ΜΑΘΗΤΗΣ/ΤΡΙΑ: "."<b>".$name." (OMP:".$omp." )"."</b>"."<br>";
$taxi='Β';
if ($taxi=='Β'){$tax='Γ';}
$_SESSION['tax']=$tax;
	$sql=  mysqli_query($con,"SELECT  * FROM electscode");
	$elects=array();
	while($row=mysqli_fetch_array($sql))
	{
	 $elects[$row['code']]=$row['mathima'];	
	}
	$sql=  mysqli_query($con,"SELECT  e.*,k.name,m.* FROM epilogesb as e,kats as k,must as m 
		   WHERE mitroo='$usr' and k.kat=e.kat and m.kat=e.kat");
	$row=mysqli_fetch_array($sql);
	$c=mysqli_num_rows($sql);
	$bkat=$row['kat'];
	$katname=$row['name'];
	$m1=$row['must1'];
	$m2=$row['must2'];
	$m3=$row['must3'];
	$elect1=$row['elect1'];
	$elect2=$row['elect2'];
	$electnum=$row['electnum'];
	$mustnum=5-$electnum;

	echo "<b>"."ΜΑΘΗΜΑΤΑ Β΄ ΛΥΚΕΙΟΥ"."</b>"."<br>";
	echo "<table style='width:900px' class='myTable' >
	<tr style='border:1px solid black' bgcolor='#819FF7'  >
	<th>ΚΑΤΕΥΘΥΝΣΗ ΣΠΟΥΔΩΝ</th>
	<th>ΥΠΟΧΡΕΩΤΙΚΑ ΜΑΘΗΜΑΤΑ</th>
	<th>ΜΑΘΗΜΑΤΑ ΕΝΔΙΑΦΕΡΟΝΤΟΣ</th> </tr>";
	echo "<tr>";
	echo "<td>".$bkat." - ".$katname."</td>";
	echo "<td>";
	echo "Νέα Ελληνικά"."<br>";
	echo $m1."<br>".$m2."<br>".$m3;
	echo "</td>";
	echo "<td>";
	$el1=$elects[$elect1];
	$el2=$elects[$elect2];
	echo $el1."<br>";
	echo $el2."<br>";
	echo "</td>";
	echo "</tr>";
	echo "</table>";
	//.....................................
	
	$sql = mysqli_query($con,"SELECT * from kats order by kat");
	?>
	<BR>
	<form name ="sample" id="ss" method="POST">
    	<p>
		<input type="button" value = "ΘΑ ΚΡΑΤΉΣΩ ΤΑ ΙΔΙΑ ΜΑΘΗΜΑΤΑ ΚΑΙ ΣΤΗ Γ΄ ΛΥΚΕΙΟΥ" onClick="submitform('epilogesin.php')" style="background-color: #819FF7;font-weight: bold; color: #ffffff;padding:4px;text-decoration:none" >
	    </p><br>
		<b> ΘΑ ΕΠΙΛΕΞΩ ΝΕΑ ΚΑΤΕΥΘΥΝΣΗ-ΜΑΘΗΜΑΤΑ: </b>
		<select style="color:gray;" name='katb'  >
        <option  value="x" >-- Επέλεξε Kατεύθυνση --</option>
        <?php
        $i=1;
        while($row = mysqli_fetch_array($sql) ) 
          { 
             $katname=$row['name'];$katv=$row['kat'];
             $p=$katv."/".$katname;
             echo "<option style='color:black;' value='$p'>$katv. $katname</option>";
          }
        ?>
        </select>
	    <input type="hidden" name="bkat"  value='<?php echo $bkat; ?>'>
		<input type="hidden" name="el1"  value='<?php echo $el1; ?>'>
		<input type="hidden" name="el2"  value='<?php echo $el2; ?>'>
		<input type="hidden" name="act"  value='<?php echo "1"; ?>'>
		
		<input type="button" value = "ΕΠΙΛΟΓΗ ΝΕΑΣ ΚΑΤΕΥΘΥΝΣΗΣ" onClick="submitform('epilog.php')" style="background-color: #819FF7;font-weight: bold; color: #ffffff;padding:4px;text-decoration:none" >
		</p>
	</form>	  
	
<BR> <BR>  <BR> <BR>  
<a  href=<?php echo $menu;?> style="background-color: #819FF7;font-weight: bold; color: #ffffff;padding:4px;text-decoration:none"  >  Ακύρωση και Επιστροφή στο Μενού  </a>

</body>
</html>