<html>
<head>
<title>Web management</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-7">
<link rel="stylesheet" href="../styles.css" type="text/css">
</head>
<script language="JavaScript">
<!--
function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') {
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (val<min || max<val) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}
//-->
</script>
<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="10">
      <?php 
			include 'connect.php';
if ($submit) {
	$sql="UPDATE infocategories SET category='$category', category_en='$category_en', category_de='$category_de', description='$description', description_en='$description_en', description_de='$description_de', publish='$publish', priority='$priority' WHERE id='$id'";
	$result = mysql_query($sql);	
?>
<table width="600" border="1" cellspacing="0" cellpadding="0" align="center" class="webadmintext" bordercolor="#999999">
  <tr> 
    <td bgcolor="#666666" bordercolor="#666666"> 
      <div align="center" class="white">H ΕΝΟΤΗΤΑ ΑΛΛΑΞΕ</div>
    </td>
  </tr>
  <tr> 
    <td bordercolor="#FFFFFF">&nbsp;</td>
  </tr>
  <tr> 
    <td bordercolor="#FFFFFF"> 
      <div align="center"><b> 
        <?php echo $category  ?>
        </b> </div>
    </td>
  </tr>
  <tr> 
    <td bordercolor="#FFFFFF">&nbsp; </td>
  </tr>
</table>
<meta http-equiv="refresh" content="0;URL=edit-infocategory.php?id=<?php echo $id ?>">
<?php
} else {	
			$result = mysql_query("SELECT * FROM infocategories WHERE id=$id",$dbh);
			$myrow=mysql_fetch_array($result); 
			$category=$myrow['category'];
			$category_en=$myrow['category_en'];
			$category_de=$myrow['category_de'];
			$description=$myrow['description'];
			$description_en=$myrow['description_en'];
			$description_de=$myrow['description_de'];
			$publish=$myrow['publish'];
			$priority=$myrow['priority'];
?>
<form name="forma" method="post" action="<?php echo $PHP_SELF ?>" enctype="multipart/form-data">
  <table width="600" border="1" cellspacing="0" cellpadding="0" align="center" class="webadmintext" bordercolor="#999999">
    <tr> 
      <td bgcolor="#666666" bordercolor="#666666"> 
        <div align="center" class="white">ΑΛΛΑΓΗ ΕΝΟΤΗΤΑΣ</div>
      </td>
    </tr>
    <tr> 
      <td bordercolor="#FFFFFF">&nbsp; </td>
    </tr>
    <tr> 
      <td bordercolor="#FFFFFF"> 
        <table width="100%" border="0" cellspacing="1" cellpadding="2" class="webadmintext" bgcolor="#F2F2F2">
          <tr> 
            <td width="30%">Ενότητα - ελληνικά* 
              <input type="hidden" name="id" value="<?php echo $id ?>">
            </td>
            <td> 
              <input type="text" name="category" maxlength="100" value="<?php echo $category ?>" class="forms" size="60">
            </td>
          </tr>
          <tr> 
            <td width="30%">Ενότητα - αγγλικά* </td>
            <td> 
              <input type="text" name="category_en" maxlength="100" value="<?php echo $category_en ?>" class="forms" size="60">
            </td>
          </tr>
          <tr> 
            <td width="30%">Ενότητα - γερμανικά</td>
            <td> 
              <input type="text" name="category_de" maxlength="100" value="<?php echo $category_de ?>" class="forms" size="60">
            </td>
          </tr>
          <tr> 
            <td width="30%">Περιγραφή - ελληνικά</td>
            <td> 
              <textarea name="description" class="forms" cols="60" rows="4"><?php echo $description ?></textarea>
            </td>
          </tr>
          <tr> 
            <td width="30%">Περιγραφή - αγγλικά</td>
            <td> 
              <textarea name="description_en" class="forms" cols="60" rows="4"><?php echo $description_en ?></textarea>
            </td>
          </tr>
          <tr> 
            <td width="30%">Περιγραφή - γερμανικά</td>
            <td> 
              <textarea name="description_de" class="forms" cols="60" rows="4"><?php echo $description_de ?></textarea>
            </td>
          </tr>
          <tr> 
            <td width="30%">Δημοσίευση στο site?</td>
            <td> 
              <?php if ($publish!=no) { ?>
              <select name="publish" class="forms">
                <option value="yes" selected>yes</option>
                <option value="no">no</option>
              </select>
              <?php }else{?>
              <select name="publish" class="forms">
                <option value="yes">yes</option>
                <option value="no" selected>no</option>
              </select>
              <?php } ?>
            </td>
          </tr>
          <tr> 
            <td width="30%">Αριθμός προτεραιότητας</td>
            <td> 
              <input type="text" name="priority" maxlength="11" value="<?php echo $priority ?>" class="forms" size="20">
            </td>
          </tr>
        </table>
      </td>
    </tr>
    <tr>
      <td bgcolor="#FFFFFF" bordercolor="#FFFFFF">&nbsp;</td>
    </tr>
    <tr bgcolor="#666666"> 
      <td bgcolor="#666666" bordercolor="#666666"> 
        <table width="300" border="0" cellspacing="0" cellpadding="0" align="center">
          <tr> 
            <td> 
              <div align="center"> 
                <input type="submit" name="submit" value="Καταχώρηση" class="button" onClick="MM_validateForm('category','','R','category_en','','R');return document.MM_returnValue">
              </div>
            </td>
            <td> 
              <div align="center"> 
                <input type="reset" name="Submit2" value="Επαναφορά" class="button">
              </div>
            </td>
          </tr>
        </table>
      </td>
    </tr>
  </table>
</form>
<?php } ?>
<table width="600" border="0" cellspacing="0" cellpadding="4" align="center">
  <tr>
    <td>
      <div align="center"> <a href="javascript:history.go(-1);"><img src="back.gif" alt="πίσω" border="0"></a> 
        &nbsp; <a href="#top"><img src="top.gif" border="0" alt="πάνω"></a> 
      </div>
    </td>
  </tr>
</table>
</body>
</html>
