<?php
include "scrinit.php";
$menu1 = $_SESSION['menu1'];
include $menu;
?>

<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 black;padding:2px;font-size:11pt; }
<p style="font-size:11px;"></p>
</style>

</script>
<script type="text/javascript" src="http://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);
}
</script>

</head>
<body>
<h3> ΑΧΑΡΑΚΤΗΡΙΣΤΕΣ ΑΠΟΥΣΙΕΣ ΤΜΗΜΑΤΟΣ</h3>

<?php 

require("dbconnect.php");
$dt=$_SESSION['dt'];
$gym=$_SESSION['gym'];

?>
	<br><h4> ΕΠΙΛΟΓΗ ΤΜΗΜΑΤΟΣ</h4> 
     <?php
    $sql2 = $dbcon->prepare("SELECT DISTINCT tmima FROM allstudentinfo order by tmima ASC");
	$sql2->execute();
    ?>
    <form method='post' />
    <label>Τμήμα:</label><select name='tmimaid' >
     
    <?php
	echo "<option value='---'>select</option>";
    while($row2=$sql2->fetch(PDO::FETCH_ASSOC)) 
	  {
          echo "<option value='$row2[tmima]'>$row2[tmima]</option>";
      }
    ?>
    </select>
    <input type="submit" name="submittm" value="Επιβεβαίωση Επιλογής" >
    </form>
<?php
if(isset($_POST['submittm']))
{
	$tmima=$_POST['tmimaid'];

echo '<p style="color: blue; text-align: left; font-weight: bold;"> ΦΩΤΟΓΡΑΦΙΕΣ ΤΜΗΜΑΤΟΣ  </p>';
echo "ΤΜΗΜΑ:".$tmima."<br>";

echo "<table  class='myTable' >
<tr style='border:1px solid black;font-size:9px' bgcolor='#d6ff73'   >
</tr>";	
$path = 'uploads/'; // upload directory
$sql=mysqli_query($con, "select mitroo,eponimo,onoma from allstudentinfo where tmima='$tmima' order by eponimo,onoma");
$rowx=mysqli_fetch_array($sql);
while (!empty($rowx))
{
	
	echo "<tr>";
	for ($i=1;$i<=5;$i++)
	{
		$mitroo=$rowx['mitroo'];
		$name=$rowx['eponimo']." ".$rowx['onoma'];
		$sqlt = $dbcon->prepare("SELECT a.mitroo,a.onoma,a.eponimo,a.pateras,p.filen,p.chkim 
			FROM allstudentinfo as a, img as p WHERE a.mitroo=? and a.mitroo=p.mitroo ");
		$sqlt->execute([$mitroo]);
		$row=$sqlt->fetch(PDO::FETCH_ASSOC);
		$count=$sqlt->rowCount();
		if ($count >0)
		{
			$img=$path.$row['filen'];
			?>
			<td>
				<img src="thumb.php?file=<?php echo $img; ?>" /><br>
				<?php
				echo $mitroo."<br>";
				echo $name;
				?>
			</td>
			<?php
		}
		else
		{
			echo "<td>";
			echo $mitroo."<br>";
			echo $name;	
			echo "</td>";
		}
		$rowx=mysqli_fetch_array($sql);
	}
	echo "</tr>";
}
}    
?>	
</table>

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