<?php
include "scrinit.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>
<script type="text/javascript">
function check(){ 
String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ""); }; 
var textAreaValue=document.getElementById('mytext').value; 
var trimmedTextAreaValue=textAreaValue.trim(); 
if(trimmedTextAreaValue!="") { 
document.forms["form1"].submit(); 
} 
} 
$(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'];
$n=$_SESSION['n'];
$name=$_SESSION['n'];
$stname=$_SESSION['stname'];
$vdname=$_SESSION['vdname'];
$vdnamek=$vdname;

if (isset($_POST['submit1'])) 
{
	$aranaforas=$_POST['aranaf'];
	$etimo="";
	$periodoi=0;
	$datetimo=$dt;

}

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;
}

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

<?php
$query = mysqli_query($con,"SELECT MAX(aranaforas) FROM kataggelia ");
$results = mysqli_fetch_array($query);
$aranaf = $results['MAX(aranaforas)'] + 1;


$result =mysqli_query($con, "SELECT Name,PMP FROM teachers ORDER BY Name ");
$sql4 = mysqli_query($con,"SELECT * FROM paraptoma ");
$sql5 = mysqli_query($con,"SELECT * FROM eidostimorias ");
$perigrafi="";
$flag=0;
$_SESSION['flag']=$flag;
?>


<form method="post" name = "form1" id="form1" action='addkataggelia.php' >
<fieldset>
ΑΡ. ΚΑΤΑΓΓΕΛΙΑΣ:<input type='text'  name= 'aranaforas' value="<?php echo $aranaf; ?>" size=6  />
&nbsp;&nbsp;&nbspΗΜΕΡ. ΚΑΤΑΓΓΕΛΙΑΣ:<input type="date"  name = 'datekata' value =<?php if (isset($_POST['dt'])) { echo $dt;$_SESSION['dt']=$dt; } else {$dt=date('Y-m-d');echo $dt;} ?>  ><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  /> <br /><br />
&nbsp;&nbsp;&nbspΒΟΗΘΟΣ:<input type='text'  name='bd' value="<?php echo $n; ?>" />  

ΚΑΤΑΓΓΕΛΙΑ ΑΠΟ: <select name='kathig'>
<?php
echo "<option value='".$usr."'>".$vdname."</option>";
while ($row = mysqli_fetch_array($result)) 
{
	$kathigitis=$row['Name'];
	$pmp=$row['PMP'];
   	echo "<option value ='".$pmp."'>".$kathigitis."</option>";
}
echo "</select>";
?>
<br /><br />

<b>ΠΑΡΑΠΤΩΜΑ ΚΑΙ ΑΙΤΙΟΛΟΓΗΣΗ ΠΑΙΔΑΓΩΓΙΚΟΥ ΜΕΤΡΟΥ ΑΠΟ ΒΔ (Αυτό το κείμενο θα φαίνεται στην επιστολή):</b><br />
<textarea name='perigrafi' cols='100' rows='5'> <?php echo ltrim($perigrafi);?> </textarea ><br/ ><br />
<input type "text"  name='sxolia' value=hidden >
<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>

<p/>
ΗΜΕΡ. ΕΠΙΒΟΛΗΣ ΜΕΤΡΟΥ:<input type="date"  name = 'datetimo' value =<?php echo $datetimo; ?>  ><br />
</p>
<p>
ΠΟΙΝΗ ΣΕ ΠΕΡΙΟΔΟΥΣ:<input type='text'  name= 'periodoi' value="<?php echo $periodoi; ?>" size=9 />

<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='text'  name= 'flag' value="<?php echo $flag; ?>" hidden />
<br /><br /> 
<button onclick='check()'> ΚΑΤΑΧΩΡΗΣΗ ΚΑΤΑΓΓΕΛΙΑΣ </button>
</fieldset>
</form>	


</body>
</html>