<?php
session_start(); // start up your PHP session! 
$menu=$_SESSION['menu'];
include $menu;
?>
<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>
<script type="text/javascript">
function confirmDelete(delcode) { 
//display confirmation window which returns true or false 
if(!window.confirm("Να προχωρήσει η διαγραφή της καταγγελίας?")) return false; 
  
//user clicked 'OK' 
window.location.href="delkata.php?id=" + delcode; 
}  
$(function() {
 $("#arsimperiforas").bind("changepara", function() {
     $.ajax({
         url: "changepara.php",
         data: "arsimperiforas="+$("#arsimperiforas").val(),
         success: function(html) {
             $("#eidostimo").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=800, height=200, 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:11px; }
<p style="font-size:09px;"></p>
</style>
<style>

</style>

</head>

<body>

<?php
require "dbconnect.php";

$usr=$_SESSION['usr'];
$name=$_SESSION['n'];
$flag=1;
$_SESSION['flag']=$flag;

$mitr=$_SESSION['mitr'];
if (isset($_POST['submit1'])) {$aranaforas=$_POST['aranaf'];}


if (isset($_GET['data'])) {
	$aranaforas=$_GET['data'];
    $sql = mysqli_query($con,"SELECT mitroo FROM kataggelia WHERE aranaforas='$aranaforas'  " );
    $row = mysqli_fetch_array($sql);
    $mitr=$row['mitroo'];$_SESSION['mitr']=$mitr;
}

?>
<h3>ΛΕΠΤΟΜΕΡΕΙΕΣ ΚΑΤΑΓΓΕΛΙΑΣ:</h3>

<?php

$sql = mysqli_query($con,"SELECT * FROM kataggelia WHERE aranaforas='$aranaforas'  " );
$row = mysqli_fetch_array($sql);
$vdidk=   $row['bd'];
$kataggelon= $row['kataggelon'];
$datekata= $row['datekata'];
$perigrafi=$row['perigrafi'];
$arsimp = $row['arsimperiforas'];
$datetimo = $row['datetimo'];
$eidostimo = $row['eidostimo'];
$periodoi = $row['periodoi'];
$katastasi = $row['katastasi'];
$sxolia = $row['sxolia'];
$timcode=$row['timoriacode'];

$sql = mysqli_query($con,"SELECT eponimo,onoma,tmima FROM allstudentinfo WHERE mitroo='$mitr'  " );
$row = mysqli_fetch_array($sql);
$stname=$row['eponimo']." ".$row['onoma'];
$tmimaid=$row['tmima'];

$sql = mysqli_query($con,"SELECT * FROM paraptoma ");
$sql5 = mysqli_query($con,"SELECT * FROM eidostimorias ");
$sql1=mysqli_query($con,"SELECT Name  FROM teachers  WHERE  PMP='$vdidk' " );
$row1 = mysqli_fetch_array($sql1);
$vdnamek = $row1['Name'];

$sql2 = mysqli_query($con,"SELECT Name FROM teachers  WHERE  PMP='$kataggelon'" );
$row2 = mysqli_fetch_array($sql2);
$teacher = $row2['Name'];


$sql3 = mysqli_query($con,"SELECT perigrafi FROM eidostimorias  WHERE  code='$timcode'" );
$row3 = mysqli_fetch_array($sql3);
$eidostimo = $row3['perigrafi'];

$sql4 = mysqli_query($con,"SELECT perigrafi,metro FROM paraptoma  WHERE  code='$arsimp'" );
$row4 = mysqli_fetch_array($sql3);
$perpara = $row4['perigrafi'];
$metro = $row4['metro'];
?>


<form method="post" name = "form1" action="addkataggelia1.php">
<fieldset style="width:1000px">
ΑΡ. ΚΑΤΑΓΓΕΛΙΑΣ:<input type='text'  name= 'aranaforas' value="<?php echo $aranaforas; ?>" size=6  /><br /><br />
ΑΡ. ΜΗΤΡΩΟΥ:<input type='text'  name= 'mitroo' value="<?php echo $mitr; ?>" size=9 /> 
&nbsp;&nbsp;&nbspΟΝΟΜΑΤΕΠΩΝΥΜΟ:<input type='text'  name= 'stname' value="<?php echo $stname; ?>" size=40  /> 
&nbsp;&nbsp;&nbspΤΜΗΜΑ:<input type='text'  name= 'tmimaid' value="<?php echo $tmimaid; ?>" size=4  />
<br /><br />
ΒΟΗΘΟΣ:<input type='text'  name='bd' value="<?php echo $vdnamek; ?>" />  

&nbsp;&nbsp;&nbspΚΑΤΑΓΓΕΛΙΑ ΑΠΟ: <input type='text'  name='kathig' value="<?php echo $teacher; ?>" /> 

<br /><br />
ΗΜΕΡ. ΚΑΤΑΓΓΕΛΙΑΣ:<input type="date"  name = 'datekata' value =<?php echo $datekata; ?>  ><br /><br />
<b>ΠΕΡΙΓΡΑΦΗ:</b><br />
<textarea name='perigrafi' cols='100' rows='8'> <?php echo ltrim($perigrafi);?> </textarea ><br/ ><br />
<p><b>
Ο ΠΕΙΘΑΡΧΙΚΟΣ ΚΩΔΙΚΑΣ ΠΑΡΑΒΙΑΣΤΗΚΕ ΣΕ ΟΤΙ ΑΦΟΡΑ:</b><br><br>
<select name='arsimpx'  >
<?php
while ($row = mysqli_fetch_array($sql)) 
{
	$arsimp1=$row['code'];
	$perig=$row['perigrafi'];
	$metro=$row['metro'];
    ?>
    <option value= '<?php echo $arsimp1;?>'  <?php if($arsimp1 == $arsimp){echo("selected");}?>> <?php echo $arsimp1." - ".$perig." - (".$metro." )";?></option>
    <?php
}
?>
</select>
<p/>
<b>ΣΧΟΛΙΑ:</b><br />
<textarea name='sxolia' cols='100' rows='3'> <?php echo ltrim($sxolia);?> </textarea ><br/ ><br />
<br /><br /> 
<input type='Submit' name='Submitkath' value='ΚΑΤΑΧΩΡΗΣΗ ΔΙΟΡΘΩΣΕΩΝ ΚΑΤΑΓΓΕΛΙΑΣ' >
</fieldset>
</form>	
<?php

echo "<br>";
echo  "<a href=\"pitharxika.php\"> <button style='color:blue'> Επιστροφή </button>". "</a>";
echo "&nbsp&nbsp&nbsp ";
?>
<a  href=<?php echo $menu;?> style="color:blue" > <button style="color:blue"> Επιστροφή στο Μενού </button></a> 
<?php echo " &nbsp&nbsp&nbsp ";?>   
<button style="color:blue " onclick="confirmDelete('<?php echo $aranaforas; ?>');">Διαγραφή της Καταγγελίας</button>
<?php echo " &nbsp&nbsp&nbsp ";?> 
<button style="color:blue " onclick="window.open('listpeda.php?metro=<?php echo $metro;?>','','width=600,height=500')">Λίστα Παιδαγωγικών Μέτρων</button>
</body>
</html>