<?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>
<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=800, height=850, top='+top+', left='+left );
}

$(document).ready(function() {

  $('#f1').submit(function() {
     
    if($("#keimeno").val().trim().length < 1)
    {
       alert("Δεν Έχετε γράψει Ανακοίνωση!");
       return false; 
    }
	

  });
		
});	

</script>

<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:12px; }
.dw{
    width:80px;
    word-wrap:break-word;
 
}
.dw1{
    width:600px;
    word-wrap:break-word;
 
}
<p style="font-size:10px;"></p>
</style>


</head>

<body>
<h2>ΑΝΑΚΟΙΝΩΣΕΙΣ ΓΙΑ ΓΟΝΕΙΣ</h2>
<?php
require "dbconnect.php"; 
$dt=$_SESSION['dt'];
$access=$_SESSION['access'];
$datein=$dt;
$dateout=$dt;

if ($access < 3) 
{
		echo " ΔΕΝ ΈΧΕΤΕ ΤΗΝ ΑΠΑΙΤΟΥΜΕΝΗ ΠΡΟΣΒΑΣΗ";
}
else
{
$sql = mysqli_query($con,"SELECT * FROM anakoinosi WHERE parents = 1 order by datein DESC  " );
$c=mysqli_num_rows($sql);
if ($c>0)
{
echo "<table  class='myTable' >
<tr style='border:1px solid black' bgcolor='#adcd82'  >
<th>Αρ.</th>
<th class='dw'>Αρχίζει</th>
<th class='dw'>Τελιώνει</th>
<th class='dw1'>Περιεχόμενο Ανακοίνωσης</th>
</tr>";	

   while ($row = mysqli_fetch_array($sql)) 
	{
		$code=$row['id'];
		$datin= $row['datein'];
		$datout= $row['dateout'];
		$perigrafi=$row['keimeno'];
		echo "<tr>";
		echo "<td>" . "<a href=\"editanakgoneis.php?data=".$code."\">"."<b>".$code."</b>". "</a>". "</td>";
		echo "<td class='dw'>". $datin . "</td>";
		echo "<td class='dw'>". $datout . "</td>";
		echo "<td class='dw1'>". $perigrafi. "</td>";
	}	

echo "</tr>"; 
echo "</table>";
}
?>
<br><br>
<form method="POST"  >
Ημερομηνία Έναρξης : <input type="date" name="datein" value= <?php echo $datein; ?>  />
Ημερομηνία Λήξης : <input type="date" name="dateout" value=<?php echo $dateout; ?> /><br>

<p><b>Κείμενο Ανακοίνωσης :<br> 
<?php
echo "<textarea name='keimeno' id='keimeno' cols='80' rows='5'> $keimeno </textarea >"."<br >";
?>
</b></p>

<input type="submit" name="anakoinosi" value="Καταχώρηση" />
</form>
<?php
if (isset($_POST['anakoinosi']))
{
	$datein=$_POST['datein'];
	$dateout=$_POST['dateout'];
	$keimeno=$_POST['keimeno'];
	mysqli_query($con,"INSERT INTO anakoinosi (id,datein,dateout,keimeno,teacher,parents) 
	                 VALUES (NULL,'$datein','$dateout','$keimeno',0,1)");	
	
	echo "<br>"."<br>";
	echo "Η ανακοίνωση έχει καταχωρηθεί από:".$datein." μέχρι: ".$dateout;
}
}	
?>
<br>
<a  href=<?php echo $menu;?> style="color:blue" > <button style="color:blue"> Επιστροφή στο Μενού </button></a>
</body>
</html>