<?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 eponimo,onoma,kinitomit,kinitotis,kinitopat,kinitotou,kinitomath,kinitoped FROM neoix");

?>
<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>ΜΑΘΗΤΗΣ/ΜΑΘΗΤΡΙΑ</th>
<th>tel </th>
<th>ΜΗΝΥΜΑ</th>
</tr>";
$i=1;
while ($row = mysqli_fetch_array($result)) 
  { 
    $name=$row['eponimo']." ".$row['onoma'];
	$p=$row['kinitotou'];
	$mi=$row['kinitotis'];
	$math=$row['kinitoped'];
	$tou=$row['kinitopat'];
	$tis=$row['kinitomit'];
	$pedi=$row['kinitomath'];
	if($p <> "ΜΑΘ" and !empty($tou)) $tel = $tou;
	if($mi <> "ΜΑΘ" and !empty($tis)) $tel = $tis;
	if($math <> "ΜΑΘ" and !empty($pedi)) $tel = $pedi;
	
	echo "<tr>";
	
	echo "<td>".$name."</td>";
	echo "<td>".$tel."</td>";
	echo "<td>"." "."</td>";
    echo "<td ALIGN=center>"."<input type='checkbox' name='smsx[]' value='$tel' >"."</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>";
	print_r($_POST['sms']);
	echo " {Έτοιμότητα αποστολής}";

	include "smssecret.php";
}	
}

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