<?php
include "scrinit.php";
include "logo.php";
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</script>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>


<?php
echo "<br>"."<br>"."<br>";
require "dbconnect.php";

$code=$_GET['id']; 
?><h3> ΑΚΥΡΩΣΗ ΠΟΙΝΗΣ ΓΙΑ ΚΑΤΑΓΓΕΛΙΑ ΜΕ ΑΡΙΘΜΟ : <?php echo $code; ?> </h3><?php
$sql = $dbcon->prepare("update kataggelia set katastasi=0 where aranaforas=? ");
$sql->execute([$code]);

$sql = $dbcon->prepare("SELECT * FROM apobolientypo WHERE timocode = ? ");
$sql->execute([$code]);
$row=$sql->fetch(PDO::FETCH_ASSOC);
$count=$sql->rowCount();
$entipo=$row['entypoid'];
$mitroo=$row['mitroo'];
$datet=$row['date'];
if ($count > 0)
{
 
mysqli_query($con,"DELETE FROM apobolientypo WHERE timocode='$code' ");
echo "<br>"."Έντυπο Αποβολής - ΟΚ";
mysqli_query($con,"DELETE FROM apoboli WHERE entypoid='$entipo' ");
echo "<br>"." Μαθήματα Αποβολής - ΟΚ";
$sql = $dbcon->prepare("SELECT code FROM ekdilosi WHERE katacode = ? ");
$sql->execute([$code]);
$count=$sql->rowCount();
while ($row=$sql->fetch(PDO::FETCH_ASSOC))
{
	$codex=$row['code'];
	mysqli_query($con,"DELETE FROM ekdilosistu WHERE code='$codex' and pmp='$mitroo' ");
}

mysqli_query($con,"DELETE FROM ekdilosi WHERE katacode='$code' ");
echo "<br>"." Εγγραφή στις Εκδηλώσεις - ΟΚ";

	
   echo '<script type="text/javascript">';
   echo 'alert("Η ΚΑΤΑΓΓΕΛΙΑ ΜΕ ΑΡΙΘΜΟ ΑΝΑΦΟΡΑΣ : ".$code." ΕΧΕΙ ΑΚΥΡΩΘΕΙ")';
   echo '</script>';	
   $time = 2; //Time (in seconds) to wait. 
   echo  "<script type='text/javascript'>";
   echo "window.close();";
   echo "</script>";
   $url = "kataggelia.php?pmp=".$mitr; //Location to send to. 
   header("Refresh: $time; url=$url");
}
else
{
   echo "Δεν έγινε οποιαδήποτε ενέργεια!";
}
	

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