<?php 
include "scrinit.php";
$menu = $_SESSION['menu'];
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>
<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>


<?php 

require("dbconnect.php");
$usr=$_SESSION['usr'];
$access=$_SESSION['access'];
$dt=$_SESSION['dt'];
$dtc= date('d-m-Y', strtotime($dt));
if ($access < 4 ) { echo " *** ΜΗ ΔΙΑΘΕΣΙΜΕΣ ΑΝΑΦΟΡΕΣ *** ";}
else
{
$result = mysqli_query($con,"SELECT tmima,eponimo,onoma,kmiteras,kpatera,kmathiti,kinito FROM allstudentinfo");

?>
<h4> ΕΠΕΛΕΞΕ ΤΟΥΣ ΜΑΘΗΤΕΣ/ΤΡΙΕΣ ΓΙΑ ΑΠΟΣΤΟΛΗ ΜΗΝΥΜΑΤΟΣ </h4>
<form  method='post' ">
<div style="overflow:scroll; border:1px solid black;background:#F5F9F0;width:550px; height: 500px">
<p>
&nbsp;&nbsp;&nbsp<input type="button" id="toggle" value="Επιλογή Όλων" onClick="do_this()" />
</p>
<?php
echo "<table style='width:500px' class='myTable' >
<tr style='border:1px solid black' bgcolor='#adcd82'  >
<th>A/A</th>
<th>ΤΜΗΜΑ</th>
<th>ΜΑΘΗΤΗΣ/ΜΑΘΗΤΡΙΑ</th>
<th>ΤΗΛΕΦΩΝΟ </th>
<th> </th>
<th>ΜΗΝΥΜΑ</th>
</tr>";
$i=1;
while ($row = mysqli_fetch_array($result)) 
  { 
    $name=$row['eponimo']." ".$row['onoma'];
	$kid=$row['kinito'];
	$math=$row['kmathiti'];
	echo "<tr>";
	echo "<td>".$i."</td>";
	echo "<td>".$row['tmima']."</td>";
	echo "<td>".$name."</td>";
	echo "<td>".$math."</td>";
	echo "<td>"." "."</td>";
    echo "<td ALIGN=center>"."<input type='checkbox' name='smsx[]' value='$math' >"."</td>";
	echo "</tr>";
    $i++;
}
echo "</table>";
?>
</div>
<p><?php 
 $sms=" ";
 echo "MHNYMA :"."<br >";; 
 echo "<textarea name='sms' cols='80' rows='2'> $sms </textarea >"."<br >";
?> </p>
<input type="submit" name="sendsms" value="Επιβεβαίωση Επιλογών" >
</form>
<?php
if (isset($_POST['sendsms']))
{
    $_SESSION['tel']=$_POST['smsx'];
	$_SESSION['sms1']=trim($_POST['sms']);
	echo "<br>";
	$_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>