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

<html>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<head>
</script>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script type="text/javascript">
$(function() {
 $("#kathig").bind("change", function() {
     $.ajax({
         url: "changeallagi.php",
         data: "kathig="+$("#kathig").val(),
         success: function(html) {
             $("#subjectid").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>

<style type="text/css">
table.myTable { border-collapse:collapse; }
table.myTable td, table.myTable th { border:1px solid black;padding:2px;font-size:12px; }
<p style="font-size:12px;"></p>
</style>
</head>
<body>
<h3> ΑΠΟΝΤΕΣ ΕΚΠΑΙΔΕΥΤΙΚΟΙ </h3>
<?php
require "dbconnect.php"; 
$usr=$_SESSION['usr'];
$dt=$_SESSION['dt'];
echo "ΗΜΕΡΟΜΗΝΙΑ: ".$dt ;
$daymap = array('Κυριακή', 'Δευτέρα', 'Τρίτη', 'Τετάρτη', 'Πέμπτη', 'Παρασκευή', 'Σάββατο');
echo "<table style='width:500px' class='myTable' >
<tr style='border:1px solid black' bgcolor='#FFAF80'  >
<th>Α/Α</th>
<th>ΠΜΠ</th>
<th>Εκπαιδευτικός</th>
<th>ΣΥΝΟΛΟ ΗΜΕΡ.</th>
</tr>";
$sql=mysqli_query($con,"SELECT a.*,t.Name from apousieskath as a,teachers as t where a.pmp=t.PMP order by pmp,datefrom ");
$i=1;
$row = mysqli_fetch_array($sql);



while(!empty($row))
{
    $pmpapon=$row['pmp'];
    
    $teach[$i]=$row['Name'];
	
    echo "<tr>";
    echo "<td>".$i."</td>";
    echo "<td>".$pmpapon."</td>";
    echo "<td >"."<b>".$teach[$i]."</b>"."</td>";
   $c=0;$tap=0;
while ($pmpapon==$row['pmp'])
{
   $datefrom=$row['datefrom'];
	$datefrom= date('d-m-Y', strtotime($datefrom));
	$dateto=$row['dateto'];
	$dateto= date('d-m-Y', strtotime($dateto));
    $perfrom=$row['perfrom'];
    $perto=$row['perto'];
    $atype=$row['type'];
    $reason=$row['reason'];
	$difdays = round((strtotime($dateto)-strtotime($datefrom))/86400)+1;
	$c=$c+$difdays;
  /*  $day = date('D', strtotime($date));
  $daytext = $daymap[date('w', strtotime($date))];
  $d1=$day."1";$d2=$day."2";$d3=$day."3";$d4=$day."4";$d5=$day."5";$d6=$day."6";$d7=$day."7";
  $result = mysqli_query($con,"SELECT id,Teacher, ".$d1.",".$d2.",".$d3.",".$d4.",".$d5.",".$d6.",".$d7." FROM timetable WHERE Teacher='$teach[$i]'");
  $rowx = mysqli_fetch_array($result);
  $ap=0;
  for($k=1;$k<=7;$k++) 
  {
      $in=$day.$k;
      $l1=$rowx["$in"];
      if ($l1 <> ""){$ap++;}
  }
  $tap=$tap+$ap;*/
  $row = mysqli_fetch_array($sql);
}
  echo "<td>".$c."</td>";
  echo "</tr>"; 
 $i++;
}
echo "</table>";
?>
<h3> ΕΚΠΑΙΔΕΥΤΙΚΟΙ ΧΩΡΙΣ ΑΠΟΥΣΙΕΣ </h3>
<?php
$sql=mysqli_query($con,"SELECT Name from teachers where access < 4  order by Name");
$i=1;$ta=array();
while ($row=mysqli_fetch_array($sql))
{
	$ta[$i]=$row['Name'];
	$i++;
}

asort($teach);
$celement = array_diff($ta,$teach);
$ll=count($celement);	 
echo $ll."<br>";

$i=1;
foreach($celement as $t) 
{
   echo "<br>".$i.". ".$t;
   $i++;
}
?>

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

</body>
</html>