<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<?php
include "logo.php";
echo "<br>"."<br>"."<br>";
date_default_timezone_set("Europe/Athens");
require "dbconnect.php";

if (isset($_POST['adeia1']))
{
	$code=$_POST['code'];
	$date=$_POST['date'];
	$date=date('Y-m-d', strtotime($date));
	$reason=$_POST['reason'];
	$kidemonas=$_POST['kidemonas'];
	$paralavi=$_POST['paralavi'];
	$tel=$_POST['tel'];
    $voithos=$_POST['voithos'];
	$perapo=$_POST['perapo'];
	$permexri=$_POST['permexri'];
	$mitr=$_POST['mitr'];
	$tmimaid=$_POST['tmimaid'];
	$stname=$_POST['stname'];
	
    $sql=mysqli_query($con,"UPDATE ekdilosi SET perapo='$perapo',permexri='$permexri' WHERE code='$code'");
    if (!$sql)) {die('Error: ' . mysqli_error($con));   }
	
$i=1;

while ($i<=7) 
{
	$met[$i]=0;
	if ($i >= $perapo AND $i <= $permexri) {$met[$i]=1;} else {$met[$i]=0;}
	$i++;
}


$sql="UPDATE ekdilosistu SET p1='$met[1]',p2='$met[2]',p3='$met[3]',p4='$met[4]',p5='$met[5]',p6='$met[6]',p7='$met[7]' WHERE code='$code'";

if (!mysqli_query($con,$sql)) die('Error: ' . mysqli_error($con));

echo "ΟΙ ΑΛΛΑΓΕΣ ΕΧΟΥΝ ΚΑΤΑΧΩΡΗΘΕΙ";
//.................
}
if (isset($_POST['adeia2']))
{
	$code=$_POST['code'];
	mysqli_query($con,"DELETE FROM ekdilosi WHERE code='$code' ");
	mysqli_query($con,"DELETE FROM ekdilosistu WHERE code='$code' ");
	
	echo "Η ΑΔΕΙΑ ΕΞΟΔΟΥ ΜΕ ΚΩΔΙΚΟ : ".$code." ΕΧΕΙ ΔΙΑΓΡΑΦΕΙ";
	
}


 ?>





</body>
</html>