<?php
include "scrinit.php";
include "logo.php";
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="https://code.jquery.com/jquery-1.9.1.min.js"></script>
<script type="text/javascript">
$(function() {
 $("#tmimaid").bind("change", function() {
     $.ajax({
         url: "change.php",
         data: "tmimaid="+$("#tmimaid").val(),
         success: function(html) {
             $("#nameid").html(html);
         }
     });
 }); 
});

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=900, height=300, top='+top+', left='+left);
}

function pop_up(url)
	{
		window.open(url,'win2','toolbar=yes, scrollbars=yes, resizable=yes, top=100, left=200, width=1200, height=800') 
	}
</script>

<style type="text/css">
table.myTable { border-collapse:collapse; }
table.myTable td, table.myTable th { border:1px solid black;padding:2px;font-size:12pt; }
<p style="font-size:14px;"></p>
</style>
</head>
<body>
<h3> COVID 19</h3>
  
<?php
require "dbconnect.php";
require_once "functions.php";
$dt=$_SESSION['dt'];
$gym=$_SESSION['gym'];
$usr=$_SESSION['usr'];
$dd=date('D', strtotime($dt));

$sql2 = mysqli_query($con,"SELECT DISTINCT tmima FROM allstudentinfo ORDER BY tmima ");
?>
<form method='post'> 

<h4> ΕΠΙΛΟΓΗ  ΜΑΘΗΤΗ/ΤΡΙΑΣ</h4>

    <label>Τμήμα:</label><select name='tmimaid' id='tmimaid'>
     
      <?php
	echo "<option value='---'>select</option>";
    while($row2 = mysqli_fetch_array($sql2) ) {
          echo "<option value='$row2[tmima]'>$row2[tmima]</option>";
      }
      ?>
     </select>
  

<label> Μαθητής/τρια:</label>

      <select name='nameid' id='nameid' value= ></select>

<input type="submit" name="submit1" value="Επιβεβαίωση Επιλογής" >
</form>

<?php 
if (isset($_POST['submit1']))
{
	$mitroo=$_POST['nameid'];
	$dd=date('D', strtotime($dt));
$tm=array();
$dayf=array(" ","Mon","Tue","Wed","Thu","Fri");
$res1=mysqli_query($con,"SELECT * FROM stutimetable WHERE mitroo='$mitroo' ");
$rows1 = mysqli_fetch_array($res1); 
$ind=1;	
for ($x=1;$x<=5;$x++)
{
	for ($per=1;$per<=$gym;$per++)
	{
			$day1=$dayf[$x].$per;
			$math= $rows1["$day1"];
			$tm[$ind]= $math;
			$ind++;
	}
}
$tm2 = array_unique($tm);

dispst($mitroo);
include "pomada1.php";


echo "<p>"."<b>"."ΚΑΤΑΛΟΓΟΣ ΤΜΗΜΑΤΩΝ"."</b></p>";
echo "<table class='myTable' >
<tr style='border:1px solid black' bgcolor='#d6ff73'  >
<th>Α/Α</th>
<th>Τμήμα</th>
</tr>";
$i=0;
$k=1;
foreach ($tm2 as $tmx)
{
	echo "<tr>";
	echo "<td>". $k. "</td>";
	echo "<td>"."<a href=\"sxediagall.php?mathid=".$tmx."\" onclick=\"pop_up(this.href);return false\">"."<b>".$tmx."</b>". "</a>". "</td>";
	echo "</tr>";
	$k++;
	$sq=mysqli_query($con,"SELECT mitroo,eponimo,onoma FROM allstudentinfo where tmima='$tmx'");
	$cc=mysqli_num_rows($sq);
	if ($cc == 0)
	{
		$sq=mysqli_query($con,"SELECT a.mitroo,a.eponimo,a.onoma FROM allstudentinfo as a, syndidaskalies as s, syndcodes as sc 
		where sc.synd='$tmx' and sc.syndid=s.syndid and s.mitroo=a.mitroo");
		
	}
	while($row=mysqli_fetch_array($sq))
	{
		$i++;
		$mit[$i]=$row[mitroo];
	}
}
echo "</table>";
$mitr=array_unique($mit);

$cc=0;
foreach ($mitr as $m)
{
    $sql = mysqli_query($con,"SELECT eponimo,onoma,tmima,kinito FROM allstudentinfo  WHERE mitroo='$m' order by tmima");
    $row=mysqli_fetch_array($sql);
	$cc++;
	$mt[$cc]=$m;
	$tmima[$cc]=$row['tmima'];
	$name[$cc]=$row['eponimo']." ".$row['onoma'];
	$kinito[$cc]=trim($row['kinito']);
}
$i=$cc;
?>	
<h3> ΑΠΟΣΤΟΛΗ ΜΗΝΥΜΑΤΩΝ</h3>
<form method="POST" action="ixnos1.php" >
<?php

echo "<BR>"."<b>"."ΚΑΤΑΛΟΓΟΣ ΜΑΘΗΤΩΝ/ΤΡΙΩΝ "."</b>";
echo "<table class='myTable' >
<tr style='border:1px solid black' bgcolor='#d6ff73'  >
<th>Α/Α</th>
<th>Α.Μητρ</th>
<th>Τμήμα</th>
<th>Όνομα</th>
<th>Κιν. Κηδεμόνα</th>
</tr>";

for ($cc=1;$cc<=$i;$cc++)
{

	echo "<tr>";
	echo "<td>". $cc . "</td>";
	echo "<td>". $mt[$cc]."</td>";
	echo "<td>". $tmima[$cc]."</td>";
	echo "<td>". $name[$cc]."</td>";
	$kin[$cc]=$kinito[$cc];
	echo "<td>". "<input type='text' name='telefk[]' value='".$kinito[$cc]."' size='10'>"."</td>";
	if (!empty($kin[$cc]))
	{
	   $x=$kin[$cc]."/".$mt[$cc]."/".$name[$cc];
	   echo "<td>". "<input type='checkbox' name='tsms[]' value='$x'  checked>" ."</td>";
	}
	else
	{
		$x=$kin[$cc]."/".$mt[$cc]."/".$name[$cc];
	    echo "<td>". "<input type='checkbox' name='tsms[]' value='$x'  unchecked>" ."</td>";	
	}
	echo "</tr>"; 
}
echo "</table>";
echo "<p>";
$sms=" ";
echo "<br >"."MHNYMA :"."<br >";; 
echo "<textarea id='mes' name='sms' cols='80' rows='3'> $sms </textarea >"."<br >";	
?>
<br>
<input type="submit" value="Αποστολη SMS " name="submit" '>
</form>
<?php
}
?>
<br><br>
<a  href=<?php echo $menu;?> style="color:blue "  > <button> Επιστροφή στο Μενού   </a> 
</body>
</html>