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

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<style type="text/css">
table.myTable { border-collapse:collapse; }
table.myTable td, table.myTable th { border:1px solid green;padding:2px;font-size:10pt; }
<p style="font-size:10px;"></p>

</style>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script type="text/javascript">
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=800, height=700, top='+top+', left='+left);
}
</script>
<body>
<h2>ΑΠΟΥΣΙΕΣ ΕΚΠΑΙΔΕΥΤΙΚΩΝ</h2>

<?php
require "dbconnect.php"; 
$dt=$_SESSION['dt'];
echo "Ημερομηνία: ".$dt;
$name = $_SESSION['n'];
$name = stripslashes($name);


$grm = array(' ','Ιανουάριος','Φεβρουάριος','Μάρτιος','Απρίλιος','Μάιος','Ιούνιος','Ιούλιος','Αύγουστος','Σεπτέμβριος','Οκτώβριος','Νοέμβριος','Δεκέμβριος');
?>

<form name = "formX3"  method="post"/>
Επέλεξε τον Μήνα για την αναφορά:<select name='minas' >
<?php
 for ($m=1; $m<=12; $m++) { 
     echo "<option  value=".$m."  >".$grm[$m]."</option>";
     }
?>	 
</select>
<input type="submit" name="smonth" value="Επιλογή" >
</fieldset>
</form>
<?php
if (isset($_POST['smonth']))
{
	$sm=$_POST['minas'];
	$minas=$grm[$sm];
    $sql=mysqli_query($con,"SELECT a.*,t.Name from apousieskath as a,teachers as t where a.pmp=t.PMP and month(datefrom)='$sm' and (type = 1 or type=2)  ");
	
?>
<h4> ΣΥΓΚΕΝΤΡΩΤΙΚΗ ΚΑΤΑΣΤΑΣΗ ΑΠΟΥΣΙΩΝ ΕΚΠΑΙΔΕΥΙΚΩΝ ΛΕΙΤΟΥΡΓΩΝ</h4>
<h4> ΓΙΑ ΤΟ ΜΗΝΑ <?php echo $minas." ".$year;?> </h4>
<?php
echo "<table style='width:1000px' class='myTable' >";
echo "<tr style='border:1px solid black' bgcolor='#adcd82'>";
echo "<td>"."Α/Α"."</td>";
echo "<td>"."Π.Μ.Π"."</td>";
echo "<td>"."ΟΝΟΜΑΤΕΠΩΝΥΜΟ"."</td>";
echo "<td colspan='4'>"."ΑΔΕΙΑ ΑΠΟΥΣΙΑΣ"."</td>";
echo "<td colspan='4'>"."ΑΔΕΙΑ ΑΣΘΕΝΕΙΑΣ"."</td>";
echo "</tr>";
echo "<tr>";
echo "<td>"." "."</td>"."<td>"." "."</td>"."<td>"." "."</td>";
echo "<td>"."Προσωπικοί λόγοι"."</td>";
echo "<td>"."Ε.Φ"."</td>";
echo "<td>"."Άλλοι λόγοι"."</td>";
echo "<td>"."Σύνολο ημερών"."</td>";
echo "<td>"."Μη πιστοποιημένη"."</td>";
echo "<td>"."Άδεια γιατρού"."</td>";
echo "<td>"."Σύνολο ημερών"."</td>";
echo "<td>"."Αντικατάσταση"."</td>";
echo "</tr>";


$i=1;
while ($row = mysqli_fetch_array($sql)) 
  { 
    $pmp=$row['pmp'];
    $name=$row['Name'];
	$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'];
	$lepto=ltrim(rtrim($row['leptomeries']));
	$anti=$row['antikatastasi'];
	$difdays = round((strtotime($dateto)-strtotime($datefrom))/86400)+1;
    
	echo "<tr>";
	echo "<td>".$i."</td>";
	echo "<td>".$pmp."</td>";
	echo "<td>".$name."</td>";
	if ($atype==1)
	{
		if ($reason==1){
		  if ($datefrom <> $dateto){$date=date('d-m', strtotime($datefrom))." -> ".$dateto;} else {$date=$datefrom;}
		     echo "<td>".$date." (".$lepto.")"."</td>";
	    }
		else {echo "<td>"." "."</td>";}
	    if ($reason==2){
		  if ($datefrom <> $dateto){$date=date('d-m', strtotime($datefrom))." -> ".$dateto;} else {$date=$datefrom;}
		      echo "<td>".$date."</td>";
	    }
		else {echo "<td>"." "."</td>";}
	    if ($reason==6){
		    if ($datefrom <> $dateto){$date=date('d-m', strtotime($datefrom))." -> ".$dateto;} else {$date=$datefrom;}
		        echo "<td>".$date." (".$lepto.")"."</td>";
	    }
		else {echo "<td>"." "."</td>";}
	    echo "<td>".$difdays."</td>";
		echo "<td>"." "."</td>";
		echo "<td>"." "."</td>";
		echo "<td>"." "."</td>";
	}
	
    if ($atype==2)
	{
		echo "<td>"." "."</td>";
		echo "<td>"." "."</td>";
		echo "<td>"." "."</td>";
		echo "<td>"." "."</td>";
	    if ($reason==3){
		   if ($datefrom <> $dateto){$date=date('d-m', strtotime($datefrom))." -> ".$dateto;} else {$date=$datefrom;}
		      echo "<td>".$date."</td>";
	    } 
		else {echo "<td>"." "."</td>";}
	    if ($reason==4){
		   if ($datefrom <> $dateto){$date=date('d-m', strtotime($datefrom))." -> ".$dateto;} else {$date=$datefrom;}
		   echo "<td>".$date."</td>";
	    }
		else {echo "<td>"." "."</td>";}
	    echo "<td>".$difdays."</td>";
		
	}
	if ($anti==0){$antik='OXI';} else {$antik='NAI';}
	echo "<td>".$antik."</td>";
	echo "</tr>";
	$i++;	
	}
echo "</table>";
}
?>	
<br />	<br />	
<a  href=<?php echo $menu;?> style="color:blue "  > <button> Επιστροφή στο Μενού   </a>
</body>
</html>