<?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:11px;"></p>
</style>

</script>
<script type="text/javascript" src="https://code.jquery.com/jquery-1.9.1.min.js"></script>
<script type="text/javascript">
$(function() {
 $("#tmimaid").bind("change", function() {
     $.ajax({
         url: "change.php",
         data: "tmimaid="+$("#tmimaid").val(),
         success: function(html) {
             $("#nameid").html(html);
         }
     });
 }); 
});


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=800, height=800, top='+top+', left='+left);
document.forms["carservice"].submit();	
}

function submitform()
{
    document.forms["carservice"].submit();
}

function pop_up(url){
window.open(url,'win2','status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=800,height=800,directories=no,location=no') 
}

</script>

</head>
<body>
<br > <br >
<h2>ΕΚΔΟΣΗ ΑΔΕΙΑΣ ΕΞΟΔΟΥ</h2>

<?php 
date_default_timezone_set("Europe/Athens");
require("dbconnect.php");
$usr=$_SESSION['usr'];
$gym=$_SESSION['gym'];
$dt=$_SESSION['dt'];
$t=date('H:i:s');
$daymap = array('Κυριακή', 'Δευτέρα', 'Τρίτη', 'Τετάρτη', 'Πέμπτη', 'Παρασκευή', 'Σάββατο');
$datedisp= date('d-m-Y', strtotime($dt)); 
$day = date('D', strtotime($dt));
$d = $daymap[date('w', strtotime($dt))];
echo "ΗΜΕΡΟΜΗΝΙΑ : "."<b>".$d. " , ".$datedisp.",".str_repeat('&nbsp;',5)." ΩΡΑ: ".$t."</b>"."<br>";
 
$sql2 = mysqli_query($con,"SELECT DISTINCT tmima FROM allstudentinfo order by tmima ASC");
$sql1=mysqli_query($con,"SELECT Name  FROM teachers  WHERE  PMP='$usr' " );
$row1 = mysqli_fetch_array($sql1);
$vdname = $row1['Name'];
$sql1=mysqli_query($con,"SELECT Name,PMP  FROM teachers where access >= 2 AND access <=4    " );
$sql3=mysqli_query($con,"SELECT * FROM reasons");


$t=time();

if     ( $t < strtotime('08:15')) {$wr=1;}
elseif ( $t < strtotime('09:00' )){$wr=2;}
elseif ( $t < strtotime('10:05' )) {$wr=3;}
elseif ( $t < strtotime('10:50' )){$wr=4;}
elseif ( $t < strtotime('11:55' )){$wr=5;}
elseif ( $t < strtotime('12:40' )){$wr=6;}
else   {$wr=7;} 
			   
if ($wr>7){$wrongt= "ΝΑ ΕΛΕΓΞΕΤΕ ΤΗΝ ΠΕΡΙΟΔΟ ΠΟΥ ΕΧΕΤΕ ΕΠΙΛΕΞΕΙ!"."( ".$wr." )";}
?>
   
<form name='dispadeia' action='dispadeia.php' method='post'>
<br >
<fieldset style="width: 700px; ">

<h4> ΕΠΙΛΟΓΗ ΠΕΡΙΟΔΟΥ, ΤΜΗΜΑΤΟΣ ΚΑΙ ΜΑΘΗΤΗ/ΤΡΙΑΣ</h4><br />
<br>
ΠΕΡΙΟΔΟΣ:<select name="ora">
 <?php
 for ($i=1;$i<=$gym;$i++)
 {
	
	 ?>
	 <option value=<?php echo $i;?> <?php if($i==$wr){echo "selected";}?> > <?php echo $i;?> </option>
	 <?php
 }
 ?>
</select>
     
	
 
    <label> &nbsp;&nbsp;&nbspΤμήμα:</label><select name='tmimaid' id='tmimaid'>
     
      <?php
	echo "<option value='---'>select</option>";
    while($row2 = mysqli_fetch_array($sql2) ) {
          echo "<option value='$row2[tmima]'>$row2[tmima]</option>";
      }
      ?>
     </select>
  

<label> &nbsp;&nbsp;&nbspΜαθητής/τρια:</label>

      <select name='nameid' id='nameid' value= ></select>
<br > <br >
ΒΟΗΘΟΣ ΔΙΕΥΘΥΝΤΗΣ:<select name='voithos'>
<?php
echo "<option value='".$usr."'>".$vdname."</option>";
while ($row1 = mysqli_fetch_array($sql1)) 
{
	$vdname = $row1['Name'];
	$usr=$row1['PMP'];
   	echo "<option value ='".$usr."'>".$vdname."</option>";
}
echo "</select>"; 
?>  
<br > <br > <br > 
ΛΟΓΟΣ :<select name='reason'>
<?php

while ($row3 = mysqli_fetch_array($sql3)) 
{
	$reason = $row3['reason'];
	echo "<option value ='".$reason."'>".$reason."</option>";
}
echo "<option value='"." "."'>"."Άλλος Λόγος"."</option>";
echo "</select>"; 
?> 
<br > <br > <br > 
<input type="submit" name="submit1" value="Συνέχεια" > 
</fieldset>
</form>


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