<?php
session_start();
ob_start();
$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() {
 $("#tmimaid").bind("change", function() {
     $.ajax({
         url: "change.php",
         data: "tmimaid="+$("#tmimaid").val(),
         success: function(html) {
             $("#nameid").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=800, top='+top+', left='+left);
document.forms["carservice"].submit();	
}

function submitform()
{
    document.forms["carservice"].submit();
}

function pop_up(url){
window.open(url,'win2','status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=800,height=800,directories=no,location=no') 
}

</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>

<?php
date_default_timezone_set("Europe/Athens");
require "dbconnect.php";
$usr=$_SESSION['usr'];
$ac=$_SESSION['access'];

$code=$_GET['data'];
$sql1 = "SELECT * FROM egkiklioi where id='$code'" ;
if (!mysqli_query($con,$sql1)) {die('Error: ' . mysqli_error($con));   }
$res=mysqli_query($con,$sql1);
$c=mysqli_num_rows($res);
$row = mysqli_fetch_array($res);

if ($ac==1 or $ac==5)
{
$sxolia=$row['sxolia'];
echo $sxolia;	
}
else
{
$res2 =mysqli_query($con, "SELECT  *  FROM teachers where access <= 5 ");

$voithos=$row['bdres'];
$teach=$row['tres'];
$datein=$row['datein'];
$perigrafi=$row['perigrafi'];
$datedue=$row['datedue'];
$status=$row['status'];
$type=$row['type'];
$url1=$row['url'];
$sxolia=$row['sxolia'];
$status=$row['status'];

/*$selected = "";
switch ($type) {
    case "1":
        $selected = "selected";
        break;
    case "2":
        $selected = "selected";
        break;
    case "3":
        $selected = "selected";
        break;
    case "4":
        $selected = "selected";
        break;
	case "5":
        $selected = "selected";
        break;	
}
*/
switch ($type) {
    case "1":
        $tpe = "ΕΓΚΥΚΛΙΟΣ";
        break;
    case "2":
        $tpe = "ΔΙΑΓΩΝΙΣΜΟΣ";
        break;
    case "3":
        $tpe = "ΣΕΜΙΝΑΡΙΟ";
        break;
    case "4":
        $tpe = "ΥΠΟΒΟΛΗ ΣΤΟΙΧΕΙΩΝ";
        break;
	case "5":
        $tpe = "ΕΝΕΡΓΕΙΕΣ";
        break;	
}

$stat = "";
switch ($status) {
    case "1":
        $stat = "selected";
        break;
    case "2":
        $stat = "selected";
        break;
    case "3":
        $stat = "selected";
        break;
    case "4":
        $stat = "selected";
        break;
	case "5":
        $stat = "selected";
        break;	
}
$sqlx=mysqli_query($con,"SELECT Name  FROM teachers WHERE  PMP='$voithos' " );
$row1 = mysqli_fetch_array($sqlx);
$vdname=$row1['Name'];

?>
<h4> ΣΤΟΙΧΕΙΑ ΕΓΚΥΚΛΙΟΥ / ΕΝΕΡΓΕΙΑΣ</h4>

<form name = "form1" action="egkactionvd1.php" method="post"/>
<fieldset style="width: 700px; ">
<p><b>ΑΡIΘΜΟΣ:</b><input type='text'  name= 'code' value="<?php echo $code; ?>" size=6  /></p>
<p>
ΗΜΕΡΟΜΗΝΙΑ:<input type='text'  name='datein' value="<?php echo $datein; ?>" />  
&nbsp&nbspΤΥΠΟΣ :<input type='text'  name='tpe' value="<?php echo $tpe; ?>" />
<input type='hidden'  name='type' value="<?php echo $type; ?>" /> 
</P>
<p>ΠΕΡΙΓΡΑΦΗ:<br />
<textarea name='perigrafi' cols='80' rows='5'> <?php echo $perigrafi;?> </textarea ></p>
<p>
ΥΠΕΥΘΥΝΟΣ ΚΑΘΗΓΗΤΗΣ/ΤΡΙΑ:<select name='tres' >
<?php
if($teach=='0')
	{
	$selected = "selected";
	}
	else
	{$selected = "";}
echo "<option ".$selected." value='0'>ΔΕΝ ΙΣΧΥΕΙ</option>";
if($teach=='1111')
	{
	$selected = "selected";
	}
	else
	{$selected = "";}
echo "<option ".$selected." value='1111'>ΟΛΟΙ</option>";
while ($row2 = mysqli_fetch_array($res2)) 
{
	$tpmp=$row2['PMP'];
	if($tpmp==$teach)
	{
	  $selected = "selected";
	}
	else
	{$selected = "";}
	$tname=$row2['Name'];
   	echo "<option ".$selected." value ='$tpmp'>$tname</option>";
}
echo "</select>";

?>
</p>
<p>
ΠΑΡΑΚΑΛΩ ΓΙΑ : <select name='status'>
  <option '$stat' value="1">1 - ΕΝΗΜΕΡΩΣΗ</option>
  <option '$stat' value="2">2 - ΕΠΕΙΓΟΝ ΕΝΕΡΓΕΙΕΣ</option>
  <option '$stat' value="3">3 - ΕΝΕΡΓΕΙΕΣ</option>
  </select>

&nbsp&nbsp ΜΕΧΡΙ:<input type="date"  name = 'datedue' value =<?php echo $datedue; ?>  ></p>
<p>


ΟΔΗΓΙΕΣ:<br />
<textarea name='sxolia' cols='80' rows='5'> <?php echo $sxolia;?> </textarea ><br/ ><br />
</p> 
<br />
<input type="submit" name="egki1" value="Ενημέρωση Στοιχείων" >
</fieldset>
</form>
<?php
}
?>
<br><br>
<a  href=<?php echo $menu;?> style="color:blue "  > <button> Επιστροφή στο Μενού   </a> 
</body>
</html>