<?php 
include "scrinit.php";
include $menu;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript">

    function do_this(){

        var checkboxes = document.getElementsByName('smsx[]');
        var button = document.getElementById('toggle');

        if(button.value == 'Επιλογή Όλων'){
            for (var i in checkboxes){
                checkboxes[i].checked = 'FALSE';
            }
            button.value = 'Αποεπιλογή Όλων'
        }else{
            for (var i in checkboxes){
                checkboxes[i].checked = '';
            }
            button.value = 'Επιλογή Όλων';
        }
    }
</script>
</head>
<style type="text/css">
table.myTable { border-collapse:collapse; }
table.myTable td, table.myTable th { border:1px solid green;padding:2px;font-size:10pt; }
<p style="font-size:10px;"></p>
</style>

<title>SMS Διεύθυνσης για διάφορα</title>

<?php 

require("dbconnect.php");
$usr=$_SESSION['usr'];
$access=$_SESSION['access'];
$dt=$_SESSION['dt'];
$dtc= date('d-m-Y', strtotime($dt));
if ($access < 2) { echo " *** ΜΗ ΔΙΑΘΕΣΙΜΕΣ ΔΙΑΔΙΚΑΣΙΕΣ *** ";}
else
{
$result = mysqli_query($con,"SELECT Name,kinito FROM teachers where (access=2 or access=3 or access=8) ORDER BY Name ");

?>
<h4> ΕΠΕΛΕΞΕ ΤΟΥΣ ΒΔ ΓΙΑ ΑΠΟΣΤΟΛΗ ΜΗΝΥΜΑΤΟΣ </h4>
<form  method='post' ">
<div style="overflow:scroll; border:1px solid black;background:#F5F9F0;width:320px; height: 450px">
<p>
&nbsp;&nbsp;&nbsp<input type="button" id="toggle" value="Επιλογή Όλων" onClick="do_this()" />
</p>

<?php
echo "<table style='width:300px' class='myTable' >
<tr style='border:1px solid black' bgcolor='#adcd82'  >
<th>ΟΝΟΜΑ ΒΟΗΘΟΥ</th>
<th> </th>
<th>SMS</th>";
$i=1;
while ($row = mysqli_fetch_array($result)) 
  { 
    $namet=$row['Name'];
	$tel = $row['kinito'];	
	echo "<tr>";
	echo "<td>".$namet."</td>";
	echo "<td>"." "."</td>";
    echo "<td ALIGN=center>"."<input type='checkbox' name='smsx[]' value='$tel' >"."</td>";
	echo "</tr>";
    $i++;
}
echo "</table>";
?>
</div>
<p>
<?php
If (isset($_POST['sms']))
	 {
		 $sms=$_POST['sms'];
	 }
else
{	
 $sms=" ";
}
 echo "MHNYMA :"."<br >";; 
 echo "<textarea name='sms' cols='100' rows='3'> $sms </textarea >"."<br >";
?>
</p>

<input type="submit" name="sendsms" value="Επιβεβαίωση Επιλογών" >
</form>
<?php
if (isset($_POST['sendsms']))
{
    $_SESSION['tel']=$_POST['smsx'];
	$sms1=trim($_POST['sms']);
	$_SESSION['sms1']=$sms1;
	$usr=$_SESSION['usr'];
	$_SESSION['fl']="teach";
	echo "<br>";
	echo "<p>"."ΘΑ ΣΤΑΛΕΙ ΤΟ ΑΚΟΛΟΥΘΟ ΜΗΝΥΜΑ :"."</p>";
	echo "<p>".$sms1."</p>";
	echo "<br>";
	echo " {Έτοιμότητα αποστολής}";
	include "smssecret.php";
}

}

?>
<br /><br />
<a  href=<?php echo $menu;?> style="color:blue "  > <button> Ακύρωση Διαδικασίας και Επιστροφή στο Μενού  </a>
</body>
</html>