<?php
include "scrinit.php";
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:11px; }
<p style="font-size:09px;"></p>
</style>
<body>

<h3>ΕΠΙΣΚΟΠΗΣΗ ΠΡΩΙΝΗΣ ΑΡΓΟΠΟΡΙΑΣ </h3>
<?php
date_default_timezone_set("Europe/Athens");
require "dbconnect.php";
$usr=$_SESSION['usr'];
$date=date('Y-m-d');
echo "<br>"."<br>";

if (isset($_POST['dt'])) {
	$date=$_POST['dt'];
	
}
// define the form into a variable
$fhtml = '<form action="" method="post">
Επέλεξε Ημερομηνία: <input type="date" name="dt" value="'. $date. '" />
 <input type="submit" value="Επιλογή Ημερομηνίας" />
</form>';

echo $fhtml;         // output /display the form
echo "<br>"."<br>";

if (isset($_POST['dt'])) {
	$date=$_POST['dt'];
echo "ΑΡΓΟΠΟΡΙΕΣ ΠΟΥ ΕΓΙΝΑΝ ΣΤΙΣ "."<b>".date('d-m-Y', strtotime($date))."</b>"."<br>"."<br>";	
}
$sql1 = "SELECT * from argoporia WHERE DATE_FORMAT(date,'%Y-%m-%d')='$date' order by bd,period" ;
if (!mysqli_query($con,$sql1)) {die('Error: ' . mysqli_error($con));   }
$res=mysqli_query($con,$sql1);
$c=mysqli_num_rows($res);

if ($c==0){echo " ΔΕΝ ΥΠΑΡΧΟΥΝ ΑΡΓΟΠΟΡΙΕΣ ΑΥΤΗ ΤΗΝ ΗΜΕΡΟΜΗΝΙΑ";}
else
{
echo "<table class='myTable' >
<tr style='border:1px solid black;font-size:9px'  >
<tr>
<th>Κωδικός</th>
<th>Μητρώο</th>
<th>Μαθητής/τρια</th>
<th>Τμήμα</th>
<th>Ημερομ.</th>
<th>Περίοδ.</th>
<th>Λεπτά</th>
<th>Βοηθός</th>
</tr>";	

while ($row = mysqli_fetch_array($res)) 
{
	$code=$row['id'];
	$mitr=$row['mitroo'];
	$per=$row['period'];
	$lepta=$row['lepta'];
	$voithos=$row['bd'];
	$date=$row['date'];
	$sql = mysqli_query($con,"SELECT eponimo,onoma,tmima FROM allstudentinfo WHERE mitroo='$mitr'  " );
    $row1 = mysqli_fetch_array($sql);
    $stname=$row1['eponimo']." ".$row1['onoma'];
    $tmimaid=$row1['tmima'];
	
	
	$sqlx=mysqli_query($con,"SELECT Name from teachers WHERE  PMP='$voithos' " );
    $row2 = mysqli_fetch_array($sqlx);
    $vdname=$row2['Name'];
	$xc=$code."/".$date."/".$mitr."/".$per;

echo "<tr>";
echo "<td>" .  "<a href=\"editargo.php?data=".$xc."\">"."<b>".$code."</b>". "</a>". "</td>";
echo "<td>" . $mitr. "</td>";
echo "<td>" . $stname. "</td>";
echo "<td align='center'>" . $tmimaid. "</td>";
echo "<td>" . $date. "</td>";
echo "<td>" . $per. "</td>";
echo "<td>" . $lepta. "</td>";
echo "<td>" . $vdname. "</td>";
echo "</tr>"; 
	
	//.............................................
}
echo "</table>";
echo "<br>"."<br>";
}
 ?>
 <br /> <br />
<a  href=<?php echo $menu;?> style="color:blue "  > <button> Επιστροφή στο Μενού   </a> 
</body>
</html>