<?php
include "scrinit.php";
include "logo.php";
?>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js">
</script>
<script type="text/javascript">
function disx()
{
	document.getElementById("sms").disabled = true;
}

function enx()
{
    document.getElementById("sms").disabled = false;
}


</script>
<style type="text/css">
input.right{  text-align:right;  }
table.myTable { border-collapse:collapse; }
table.myTable td, table.myTable th { border:1px solid black;padding:2px;font-size:10pt; }
</style>
</script>

</head>

<body>
<h3> ΕΛΕΓΧΟΣ ΦΩΤΟΓΡΑΦΙΩΝ ΑΠΟΛΥΤΗΡΙΟΥ</h3>

<?php
require "dbconnect.php"; 
$usr=$_SESSION['usr'];
$yt=0;
if(isset($_POST['submittm']))
{
	$tmima=$_POST['tmimaid'];
	$yt=1;
}
else
{
	$sql = mysqli_query($con,"SELECT * from voithos where yt='$usr'");
	if (mysqli_num_rows($sql) > 0)
	{
	  $yt=1;
	  $row=mysqli_fetch_array($sql);
	  $tmima= $row['Class_id'];
	}
}
if ($yt <> 1)
{
	echo "ΜΗ ΔΙΑΘΕΣΙΜΗ ΑΝΑΦΟΡΑ";
}
else
{
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'];
			$chk=$row['chkim'];
			if ($chk == 1 ) $stc='Lime';
			if ($chk == 0 ) $stc='#95B9C7';
			if ($chk == 9 ) $stc='Red';
			?>
			<td style="background-color: <?php echo $stc; ?>;">
				<img src="thumb.php?file=<?php echo $img; ?>" /><br>
				<?php
				echo $mitroo."<br>";
				echo $name."<br>";
				if ($chk == 1 ) echo "ΑΠΟΔΕΧΤΗ";
				if ($chk == 0 ) echo "ΕΚΚΡΕΜΕΙ";
				if ($chk == 9 ) echo "ΑΠΟΡΡΙΦΘΗΚΕ";
					
				
				?>
			</td>
			<?php
		}
		else
		{
			echo "<td>";
			echo $mitroo."<br>";
			echo $name;	
			echo "</td>";
		}
		$rowx=mysqli_fetch_array($sql);
	}
	echo "</tr>";
}
}    
?>	
</table>
<br><br>

</body>
</html>