<?php
session_start();
ob_start();
if ($_SESSION['islogin']=='' ) { 
  echo "ΠΡΕΠΕΙ ΝΑ ΕΓΓΡΑΦΕΙΤΕ ΓΙΑ ΝΑ ΧΡΗΣΙΜΟΠΟΙΗΣΕΤΕ ΤΟ ΣΥΣΤΗΜΑ"."<BR>";
  sleep(3);
  header("Location: loginall.php"); /* Redirect browser */
  exit();
  }
$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'];

$code=$_GET['data'];
$res1 =mysqli_query($con, "SELECT  *  FROM vd ");
$res2 =mysqli_query($con, "SELECT  *  FROM teachers where access <= 5 ");
$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);
$i=1;
$row = mysqli_fetch_array($res);
$voithos=$row['bdres'];
$teach[$i]=$row['tres'];
$datein=$row['datein'];
$perigrafi=$row['perigrafi'];
$datedue=$row['datedue'];
$status=$row['status'];
$type=$row['type'];
$url1=$row['url'];
$sxolia=$row['axolia'];
$status=$row['status'];

while ($row = mysqli_fetch_array($res))
{
  $i++;
  $teach[$i]=$row['tres'];	
}

$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;	
}
$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="editegkiklios1.php" method="post"/>
<fieldset style="width: 1100px; ">
<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ΤΥΠΟΣ :<select name='type'>
  <option '$selected' value="1">1 - ΕΓΚΥΚΛΙΟΣ</option>
  <option '$selected' value="2">2 - ΔΙΑΓΩΝΙΣΜΟΣ</option>
  <option '$selected' value="3">3 - ΣΕΜΙΝΑΡΙΟ</option>
  <option '$selected' value="4">4 - ΥΠΟΒΟΛΗ ΣΤΟΙΧΕΙΩΝ</option>
  <option '$selected' value="5">5 - ΕΝΕΡΓΕΙΑ</option>
</select>
</P
ΠΕΡΙΓΡΑΦΗ:<br />
<textarea name='perigrafi' cols='80' rows='5'> <?php echo $perigrafi;?> </textarea ><br/ ><br />
<p>
ΔΙΕΥΘΥΝΣΗ ΑΝΑΦΟΡΑΣ:<input type="text"  name = 'url1' value =<?php echo $url1; ?> size=60>
ΕΝΕΡΓΕΙΕΣ ΜΕΧΡΙ:<input type="date"  name = 'datedue' value =<?php echo $datedue; ?>  ></p>
<p>
ΥΠΕΥΘΥΝΟΣ ΒΔ/ΒΔΑ:<select name='bdres' multiple >
<?php
if($voithos=='1111')
	{
	$selected = "selected";
	}
	else
	{$selected = "";}
echo "<option ".$selected." value='1111'>ΟΛΟΙ</option>";
while ($row1 = mysqli_fetch_array($res1)) 
{
	$vdpmp=$row1['voi_id'];
	if($vdpmp==$voithos)
	{
	  $selected = "selected";
	}
	else
	{$selected = "";}
	$vdname=$row1['voi_name'];
   	echo "<option ".$selected." value ='$vdpmp'>$vdname</option>";
}
echo "</select>";
?>
 &nbsp&nbspΥΠΕΥΘΥΝΟΣ ΚΑΘΗΓΗΤΗΣ/ΤΡΙΑ:<select name='tres' multiple >
<?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>";
?>
&nbsp&nbspΕΝΕΡΓΕΙΕΣ :<select name='status'>
  <option '$stat' value="1">1 - ΝΑΙ</option>
  <option '$stat' value="2">2 - ΓΙΑ ΕΝΗΜΕΡΩΣΗ</option>
  <option '$stat' value="3">3 - ΣΕ ΔΙΑΔΙΚΑΣΙΑ</option>
  <option '$stat' value="4">4 - ΟΛΟΚΛΗΡΩΘΗΚΕ</option>
  <option '$stat' value="5">5 - ΕΠΕΙΓΟΝ</option>
</select>
<p>
ΣΧΟΛΙΑ:<br />
<textarea name='sxolia' cols='80' rows='5'> <?php echo $sxolia;?> </textarea ><br/ ><br />
</p> 
<br />
<input type="submit" name="egki1" value="Διόρθωση Στοιχείων" >
&nbsp&nbsp
<input type="submit" name="egkidel" value="Διαγραφή Εγκυκλίου" onclick="return confirm('ΕΙΣΑΣΤΕ ΣΙΓΟΥΡΟΙ ΓΙΑ ΤΗ ΔΙΑΓΡΑΦΗ?')">

</fieldset>
</form>

<?php


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