<?php
include "scrinit.php";
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() {
 $("#arsimperiforas").bind("changepara", function() {
     $.ajax({
         url: "changepara.php",
         data: "arsimperiforas="+$("#arsimperiforas").val(),
         success: function(html) {
             $("#eidostimo").html(html);
         }
     });
 }); 
});
function confirmDelete(delcode) { 
//display confirmation window which returns true or false 
if(!window.confirm("Να προχωρήσει η διαγραφή της καταγγελίας?")) return false; 
  
//user clicked 'OK' 
window.location.href="delkatabd.php?id=" + delcode; 
} 
function confirmakir(delcode) { 
//display confirmation window which returns true or false 
if(!window.confirm("Να προχωρήσει η ακύρωση της διεκπεραίωσης της καταγγελίας?")) return false; 
  
//user clicked 'OK' 
window.location.href="akirosikat.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);
}
function pop_up(url){
		window.open(url,'win2','toolbar=yes, scrollbars=yes, resizable=yes, top=100, left=100, width=1000, height=300') 
	}
	
</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>

</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'])) {
	$ar=explode("/",$_GET['data']);
	$aranaforas=$ar[0];
	$fl=$ar[1];
    $sql = $dbcon->prepare("SELECT mitroo FROM kataggelia WHERE aranaforas=?  " );
    $sql->execute([$aranaforas]);
    $row=$sql->fetch(PDO::FETCH_ASSOC);
    $mitroo=$row['mitroo'];
}

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

<?php

$sql = $dbcon->prepare("SELECT * FROM kataggelia WHERE aranaforas=? " );
$sql->execute([$aranaforas]);
$row=$sql->fetch(PDO::FETCH_ASSOC);
$vdidk=   $row['bd'];
$kataggelon= $row['kataggelon'];
$datekata= $row['datekata'];
$perigrafi=$row['perigrafi'];
$arsimp = $row['arsimperiforas'];
$datetimo = $row['datetimo'];
$etimo = $row['eidostimo'];
$periodoi = $row['periodoi'];
$katastasi = $row['katastasi'];
$sxolia = $row['sxolia'];
$timcode=$row['timoriacode'];

$sql = $dbcon->prepare("SELECT eponimo,onoma,tmima FROM allstudentinfo WHERE mitroo=?  " );
$sql->execute([$mitroo]);
$row=$sql->fetch(PDO::FETCH_ASSOC);
$stname=$row['eponimo']." ".$row['onoma'];
$tmimaid=$row['tmima'];

//$sql = mysqli_query($con,"SELECT * FROM paraptoma ");

$sql5 = mysqli_query($con,"SELECT * FROM eidostimorias ");
$sql1 = $dbcon->prepare("SELECT Name  FROM teachers  WHERE  PMP=? " );
$sql1->execute([$vdidk]);
$row1=$sql1->fetch(PDO::FETCH_ASSOC);
$vdnamek = $row1['Name'];

$sql2 = $dbcon->prepare("SELECT Name FROM teachers  WHERE  PMP=? " );
$sql2->execute([$kataggelon]);
$row2=$sql2->fetch(PDO::FETCH_ASSOC);
$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 * FROM paraptoma " );
?>

<form method="post" name = "form1" action="addkataggelia.php">
<fieldset>
ΑΡ. ΚΑΤΑΓΓΕΛΙΑΣ:<input type='text'  name= 'aranaforas' value="<?php echo $aranaforas; ?>" size=6  />
&nbsp;&nbsp;&nbspΗΜΕΡ. ΚΑΤΑΓΓΕΛΙΑΣ:<input type="date"  name = 'datekata' value =<?php echo $datekata; ?>  ><br /><br />
ΑΡ. ΜΗΤΡΩΟΥ:<?php
echo "<td>"."<a href=\"show.php?mit=".$mitroo."\" onclick=\"pop_up(this.href);return false\">"."<b>".$mitroo."</b>". "</a>". "</td>";?>
&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 />

<b>ΠΕΡΙΓΡΑΦΗ ΠΑΡΑΠΤΩΜΑΤΟΣ ΑΠΟ ΚΑΤΑΓΓΕΛΛΟΝΤΑ:</b><br />
<textarea name='perigrafi' cols='100' rows='5'> <?php echo ltrim($perigrafi);?> </textarea ><br/ ><br />
<b>ΠΑΡΑΠΤΩΜΑ ΚΑΙ ΑΙΤΙΟΛΟΓΗΣΗ ΠΑΙΔΑΓΩΓΙΚΟΥ ΜΕΤΡΟΥ ΑΠΟ ΒΔ (Αυτό το κείμενο θα φαίνεται στην επιστολή):</b><br />
<textarea name='sxolia' cols='100' rows='6'> <?php echo ltrim($sxolia);?> </textarea ><br/ ><br />
<table>
<tr><td>
<b>Ο ΠΕΙΘΑΡΧΙΚΟΣ ΚΩΔΙΚΑΣ ΠΑΡΑΒΙΑΣΤΗΚΕ ΣΕ ΟΤΙ ΑΦΟΡΑ:</b><br>
<select name='arsimpx'  >
<?php
while ($row4 = mysqli_fetch_array($sql4)) 
{
	$arsimp1=$row4['code'];
	$perig=$row4['perigrafi'];
	$metro=$row4['metro'];
    ?>
    <option value= '<?php echo $arsimp1;?>'  <?php if($arsimp1 == $arsimp){echo("selected");}?>> <?php echo $arsimp1." - ".$perig." - (".$metro." )";?></option>
    <?php
}
?>
</select>
</td>
<td>
<b>ΕΠΙΒΟΛΗ ΠΑΙΔΑΓΩΓΙΚΟΥ ΜΕΤΡΟΥ:</b><br>
<select name='metrox'  >
<?php
while ($row5 = mysqli_fetch_array($sql5)) 
{
	$code1=$row5['code'];
	$perig=$row5['perigrafi'];
	?>
    <option value= '<?php echo $code1;?>'  <?php if($code1 == $timcode){echo("selected");}?>> <?php echo $code1." - ".$perig;?></option>
    <?php
}
?>
</select>
</td></tr></table>
<?php if (is_null($datetimo)) $datetimo=$dt;?>
<p/>
ΗΜΕΡ. ΕΠΙΒΟΛΗΣ ΜΕΤΡΟΥ:<input type="date"  name = 'datetimo' value =<?php echo $datetimo;?> <?php echo "required";?> ><br />
</p>
<p>
ΠΟΙΝΗ ΣΕ ΠΕΡΙΟΔΟΥΣ:<input type='text'  name= 'periodoi' value="<?php echo $periodoi; ?>" size=9 required />

<Input type = 'Radio' name ='etimo' value= '0' <?php if ($etimo==0) {echo 'checked';} else {echo "";}?> >ΜΕ ΑΝΑΣΤΟΛΗ/ΑΛΛΗ (αρ. περιόδων)</td>
<Input type = 'Radio' name ='etimo' value= '1' <?php if ($etimo==1) {echo 'checked';} else {echo "";}?> >ΚΑΤ' ΟΙΚΟΝ </td>
<Input type = 'Radio' name ='etimo' value= '2' <?php if ($etimo==2) {echo 'checked';} else {echo "";}?> >ΑΠΟΒΟΛΗ </td>
</p>

<input type='hidden'  name= 'mitroo' value="<?php echo $mitroo; ?>" >
<input type='hidden'  name= 'flag' value="<?php echo $flag; ?>" hidden />
<br /><br /> 
<input type='Submit' name='Submit' value='ΚΑΤΑΧΩΡΗΣΗ ΚΑΤΑΓΓΕΛΙΑΣ'  >
</fieldset>
</form>	
<?php
echo "<br>";
if ($fl=="1")
{
echo  "<a href=\"newmath.php?fn=1\"> <button style='color:blue'> Επιστροφή </button>". "</a>";
}
else
{
echo  "<a href=\"kataggelia.php?pmp=".$mitroo."\"> <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
if ($vdidk==$usr)
{
  echo " &nbsp&nbsp&nbsp ";?>   
  <button style="color:blue " onclick="confirmDelete('<?php echo $aranaforas; ?>');">Διαγραφή της Καταγγελίας</button>  
  <?php
}
echo " &nbsp&nbsp&nbsp ";?> 
<button style="color:blue " onclick="confirmakir('<?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>