<?php 
include "scrinit.php";
require_once ("functions.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" />
<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 < 1) { echo " *** ΜΗ ΔΙΑΘΕΣΙΜΕΣ ΑΝΑΦΟΡΕΣ *** ";}
else
{
$t1='';$t2='';$t3='';
if (isset($_POST['epiltaxi'])) $tax = $_POST['taxi1'];
$tax=array();
$tax = $_REQUEST['taxi'];
if(isset($_GET['taxi']))
{
	$tax = $_GET['taxi'];
	if($tax=="Α") $t1='checked';
	if($tax=="Β") $t2='checked';
	if($tax=="Γ") $t3='checked';
	?>
    <script type="text/javascript">
      document.getElementById('tform').submit(); // SUBMIT FORM
    </script>
	<?php
}

if($tax=="Α") $t1='checked';
if($tax=="Β") $t2='checked';
if($tax=="Γ") $t3='checked';
?>
<h4> ΕΠΙΛΟΓΗ ΤΑΞΗΣ</h4>
<form  id='tform' method='post' >
<Input type = 'Radio' Name ='taxi1' value= 'Α' <?php echo $t1;?>>Α ΤΑΞΗ
<Input type = 'Radio' Name ='taxi1' value= 'Β' <?php echo $t2;?>>Β ΤΑΞΗ
<Input type = 'Radio' Name ='taxi1' value= 'Γ' <?php echo $t3;?>>Γ ΤΑΞΗ
<br><br>
<input type="submit" name="epiltaxi" value="Επιλογή Τάξης">
</form>
<br>

<?php

if (isset($_POST['epiltaxi']))
{
  $_SERVER['PHP_SELF'];	
  $tax = $_POST['taxi1'];
if ($tax=='Α')
{
	$result = mysqli_query($con,"SELECT tmima,mitroo,eponimo,onoma FROM allstudentinfo  
	where tmima like '".$tax."%' or tmima = 'ΜΝΔ' ORDER BY tmima,eponimo,onoma");
}
else
{
	$result = mysqli_query($con,"SELECT tmima,mitroo,eponimo,onoma FROM allstudentinfo  
	where tmima like '".$tax."%' ORDER BY tmima,eponimo,onoma");	
}
$cov = mysqli_query($con,"SELECT * FROM spiticovid ");
while ($row = mysqli_fetch_array($cov)) 
  { 
    $mitroo=$row['mitroo'];
	$mit[$mitroo]=$mitroo;
	$d1[$mitroo]=$row['dateout'];
	$d2[$mitroo]=$row['dateback'];
	$r[$mitroo]=$row['reason'];
	$x = strtotime("+2 day", strtotime($dt));
	if ($r[$mitroo]=='1') $d3[$mitroo]=date('Y-m-d', strtotime($d1[$mitroo].' + 14 days'));
	if ($r[$mitroo]=='2') $d3[$mitroo]=date('Y-m-d', strtotime($d1[$mitroo].' + 14 days'));
  }

?>
<form  method='post' action='covidlist1.php'>

<h4>ΕΠΕΛΕΞΕ ΜΑΘΗΤΗ/ΤΕΣ </h4>
<div style="overflow:scroll; border:1px solid black;background:#F5F9F0;width:920px; height: 600px">
<?php
echo "<table style='width:900px' class='myTable' >
<tr style='border:1px solid black' bgcolor='#adcd82'  >
<th>ΤΜΗΜΑ</th>
<th>ΜΗΤΡΩΟ</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'];
	$mitroo=$row['mitroo'];
	$tmima=$row['tmima'];
	$chk='';
	if ($mit[$mitroo]==$mitroo) $chk="checked"; 
	echo "<tr>";
	echo "<td>".$tmima."</td>";
	echo "<td>".$mitroo."</td>";
	echo "<td>".$name."</td>";
	echo "<td>"."<input type='checkbox' name='mitr[]' value='$mitroo' {$chk}>"."</td>";
	echo "<td>"."<input type='date' name='d1[]' value='$d1[$mitroo]' >"."</td>";
	echo "<td>"."<input type='date' name='d2[]' value='$d3[$mitroo]' >"."</td>";
	$v1="1/".$mitroo;
	$v2="2/".$mitroo;
	$v3="3/".$mitroo;
	$x=$r[$mitroo];
	$s1='';$s2='';$s3='';$s4='';
	if($x == '1') $s1='selected';
	if($x == '2') $s2='selected';
	if($x == '3') $s3='selected';
	if($x == NULL) $s4='selected';
	
	?>
	<input type='hidden' name='tax' value='<?php echo $tax;?>'>
	<td>
	<select name="logos[]" >
	<option <?php echo $s1; ?> value='<?php echo $v1;?>'>ΚΡΟΥΣΜΑ</option> 
	<option <?php echo $s2; ?> value='<?php echo $v2;?>'>ΕΠΑΦΗ</option> 
	<option <?php echo $s3; ?> value='<?php echo $v3;?>'>Ε-ΟΜΑΔΑ</option>
	<option <?php echo $s4; ?> value=0 >      </option>
	</select>
	</td>
	<?php
	echo "</tr>";
    $i++;
}
echo "</table>";
?>
</div>

<input type="submit" name="subcovid" value="Καταχώρηση δεδομένων" >
</form>

<?php
}
}
?>

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