<?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:2px solid black;padding:4px;font-size:14px; }
<p style="font-size:10px;"></p>
</style>

<h2>ΔΙΑΤΑΚΤΙΚΑ ΣΧΟΛΙΚΗΣ ΕΦΟΡΕΙΑΣ</h2>
<?php
require "dbconnect.php";
$usr=$_SESSION['usr'];

$query = mysqli_query($con,"SELECT MAX(dnum) FROM diataktiko ");
$results = mysqli_fetch_array($query);
$dnew = $results['MAX(dnum)'] + 1;


?><h3>ΚΑΤΑΧΩΡΙΣΜΕΝΑ ΔΙΑΤΑΚΤΙΚΑ</h3><?php
echo "<table class='myTable' >
<tr style='border:2px solid black;padding:4px;font-size:14px'  >
<tr>
<th>Αρ.Διατακτικού</th>
<th>Ημερομηνία</th>
<th>Χειρόγραφο</th>
<th>Κατάσταση</th>
</tr>";	
$sql = mysqli_query($con,"SELECT * FROM diataktiko order by datein desc" );

echo "<tr>";
echo "<br>";
echo "<td>"."<a href=\"diataktiko.php?data=".$dnew."\">"."<b>".$dnew."</b>". "</a>". "</td>";
echo "<td colspan= '3' >" . "<a href=\"diataktiko.php?data=".$dnew."\">"."<b>"."ΝΕΟ ΔΙΑΤΑΚΤΙΚΟ"."</b>". "</a>". "</td>";
echo "<br>";
echo "</tr>"; 
if ($dnew==1)
{ 
	echo "<tr>";
	echo " ΔΕΝ ΥΠΑΡΧΟΥΝ ΚΑΤΑΧΩΡΙΣΜΕΝΑ ΔΙΑΤΑΚΤΙΚΑ ";
	echo "</tr>";	
}
else
{
	while ($row = mysqli_fetch_array($sql)) 
	{
		$dn=$row['dnum'];
		$rn=$row['dreal'];	
		$din=   $row['datein'];
		$dindisp= date('d-m-Y', strtotime($din));

		echo "<tr>";
		echo "<td>" . "<a href=\"diataktiko.php?data=".$dn."\">"."<b>".$dn."</b>". "</a>". "</td>";
		echo "<td>". $dindisp . "</td>";
		echo "<td>". $rn . "</td>";
		$q1=mysqli_query($con,"select * from diadetail where dnum='$dn'");
		$njob=0;
		while($row1=mysqli_fetch_array($q1))
		{
			if ($row1['datedone'] <= 0) $njob=1;
		}
		if($njob == 0 ) echo "<td>". "Ολοκληρώθηκε" . "</td>"; 
		if($njob == 1 ) echo "<td>". "Εκκρεμεί" . "</td>";
		echo "</tr>"; 
	}
}

echo "</table>";
echo "<br>"."<br>";	

 ?>

<br /><br /><br /><br />

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