<?php
session_start();
$menu=$_SESSION['menu'];
include $menu;
?>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Απουσίες Μαθήματος</title>
<style type="text/css">
table.myTable { border-collapse:collapse; }
table.myTable td, table.myTable th { border:1px solid black;padding:2px;font-size:10pt; }
<p style="font-size:10px;"></p>
</style>

</head>

<body>
<h2>ΑΝΑΚΟΙΝΩΣΕΙΣ</h2>
<?php
require "dbconnect.php"; 

$dt=$_SESSION['dt'];
$datein=$dt;
$dateout=$dt;
echo "<br>"."ΗΜΕΡΟΜΗΝΙΑ:".$dt;
echo "<br>"; 
echo "<br>"; 
$sql = "SELECT Name,PMP FROM teachers ORDER BY Name ";
$result = mysqli_query($con,$sql);
?>
<form method="POST"  action="anakoinosi1.php">
Ημερομηνία Έναρξης : <input type="date" name="datein" value= <?php echo $datein; ?>  />
Ημερομηνία Λήξης : <input type="date" name="dateout" value=<?php echo $dateout; ?> /><br>
<br><br>
Προς Καθηγητή/τρια :<br>
<select name='kathigitis[]' size='10' multiple >
<?php
echo "<option value ='ALL'>ΠΡΟΣ ΟΛΟΥΣ ΤΟΥΣ ΚΑΘΗΓΗΤΕΣ</option>";
while ($row = mysqli_fetch_array($result)) 
{
	$kathigitis=$row['Name'];
	$pmp=$row['PMP'];
	echo "<option value ='".$pmp."'>".$kathigitis."</option>";
}
echo "</select>";
?>
<br><br>
<br>Ανακοίνωση : 
<?php
echo "<textarea name='keimeno' cols='80' rows='4'> $keimeno </textarea >"."<br >";
?>
<br><br>
<input type="submit" name="anakoinosi" value="Καταχώρηση" />
</form>
<?php
if (isset($_POST['anakoinosi']))
{
	$datein=$_POST['datein'];
	$dateout=$_POST['dateout'];
	$keimeno=$_POST['keimeno'];
	$teach = $_POST['kathigitis'];
	if (count($teach)== 1 AND $teach[0]=='ALL') 
	{
		$t=$teach[0];
	    mysqli_query($con,"INSERT INTO anakoinosi (id,datein,dateout,keimeno,teacher,parents) 
	                 VALUES (NULL,'$datein','$dateout','$keimeno',0,0)");	
	}
	else
	{
     foreach ($teach as $t){
     mysqli_query($con,"INSERT INTO anakoinosi (id,datein,dateout,keimeno,teacher,parents) 
	 VALUES (NULL,'$datein','$dateout','$keimeno','$t',0)");}
    }
}
	
?>
<br />
<a  href=<?php echo $menu; ?>  style="color:blue "  >  Επιστροφή στο Μενού  </a>

</body>
</html>