<?php
session_start();
ob_start();
if ($_SESSION['islogin']=='' ) { 
  echo "ΠΡΕΠΕΙ ΝΑ ΕΓΓΡΑΦΕΙΤΕ ΓΙΑ ΝΑ ΧΡΗΣΙΜΟΠΟΙΗΣΕΤΕ ΤΟ ΣΥΣΤΗΜΑ"."<BR>";
  sleep(3);
  header("Location: loginall.php"); /* Redirect browser */
  exit();
  }
date_default_timezone_set("Europe/Athens");
require "dbconnect.php";
$usr=$_SESSION['usr'];
$dt=$_SESSION['dt'];
$access=$_SESSION['access'];  
$menu = $_SESSION['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>


<?php
date_default_timezone_set("Europe/Athens");
require "dbconnect.php";
$date=$dt;
if ($access > 1)
{	
  $sql1 = "SELECT * FROM egkiklioi WHERE status <> '4' and (bdres='$usr' or bdres='1111') order by datedue asc " ;
}
else
{
  $sql1 = "SELECT * FROM egkiklioi WHERE status <> '4' and (tres='$usr' or tres='1111') order by datedue asc " ;	
}
if (!mysqli_query($con,$sql1)) {die('Error: ' . mysqli_error($con));   }
$res=mysqli_query($con,$sql1);
$c=mysqli_num_rows($res);

if ($c>0)
{
?>
<h3>ΕΠΙΣΚΟΠΗΣΗ ΕΚΓΥΚΛΙΩΝ </h3>
<?php
echo "<table style='width:1000px' class='myTable' >
<tr style='border:1px solid black' bgcolor='#819FF7'  >
<th>Κωδ.</th>
<th>Ημερ.Κατ</th>
<th>Περιγραφή</th>
<th>Διεύθυνση</th>
<th>Ημερ.Δράσης</th>
<th>Λόγος</th>
<th>Κατάσταση</th>
</tr>";	

while ($row = mysqli_fetch_array($res)) 
{
	$code=$row['id'];
	$voithos=$row['bdres'];
	$teach=$row['tres'];
	$perigrafi=$row['perigrafi'];
	$url=$row['url'];
	$datedue=$row['datedue'];
	$datein=$row['datein'];
	$status=$row['status'];
	$stat='';
	switch ($status) {
    case "1":
        $stat = "ΕΝΗΜΕΡΩΣΗ";
        break;
    case "2":
        $stat = "ΕΠΕΙΓΟΥΣΕΣ ΕΝΕΡΓΕΙΕΣ ";
        break;
    case "3":
        $stat = "ΕΝΕΡΓΕΙΕΣ";
        break;	
    }
	
	if ($voithos<>"1111")
	{		
	$sqlx=mysqli_query($con,"SELECT Name  FROM teachers  WHERE  PMP='$voithos' " );
    $row2 = mysqli_fetch_array($sqlx);
    $vdname=$row2['Name'];
	}
	else
	{
	$vdname="*";	
	}
	if ($teach <>"1111" AND $teach <> '0')
	{		
	$sqlx=mysqli_query($con,"SELECT Name  FROM teachers  WHERE  PMP='$teach' " );
    $row2 = mysqli_fetch_array($sqlx);
    $tname=$row2['Name'];
	}
	elseif($teach <>"1111")
	{
		   $tname="ΔΕΝ ΙΣΧΥΕΙ";	
	}
	else
	{
	       $tname="*";	
	}
	$view='checked';

echo "<tr>";
if ($access > 1 and $access <=4)
{
echo "<td>" . "<a href=\"egkactionvd.php?data=".$code."\" >"."<b>".$code."</b>". "</a>". "</td>";
}
else
{
echo "<td>" . "<b>".$code."</b>".  "</td>";	
}
echo "<td>" . $datein. "</td>";
echo "<td>" . $perigrafi. "</td>";
echo "<td>" . "<a href='$url' target='_blank'>"."<b>".$url."</b>". "</a>". "</td>";
echo "<td>" . $datedue. "</td>";
echo "<td>" . $stat. "</td>";
echo "<td>" . "". "</td>";
echo "</tr>"; 
	
	//.............................................
}
echo "</table>";
echo "<br>"."<br>";
}
 ?>
 <br /> <br />
</body>
</html>