<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Web management</title>
<link rel="stylesheet" href="styles.css" type="text/css">
<?php include 'codes.php';?>
</head>
<body text="#000000" style="margin:0">
<?php 
$id = mysql_real_escape_string(stripslashes($_REQUEST['id']));
$category = mysql_real_escape_string(stripslashes($_REQUEST['category']));
$category_en = mysql_real_escape_string(stripslashes($_REQUEST['category_en']));
$category_de = mysql_real_escape_string(stripslashes($_REQUEST['category_de']));
$category_fr = mysql_real_escape_string(stripslashes($_REQUEST['category_fr']));
$category_it = mysql_real_escape_string(stripslashes($_REQUEST['category_it']));
$category_es = mysql_real_escape_string(stripslashes($_REQUEST['category_es']));
$category_ru = mysql_real_escape_string(stripslashes($_REQUEST['category_ru']));
$category_zh = mysql_real_escape_string(stripslashes($_REQUEST['category_zh']));
$description = mysql_real_escape_string(stripslashes($_REQUEST['description']));
$description_en = mysql_real_escape_string(stripslashes($_REQUEST['description_en']));
$description_de = mysql_real_escape_string(stripslashes($_REQUEST['description_de']));
$description_fr = mysql_real_escape_string(stripslashes($_REQUEST['description_fr']));
$description_it = mysql_real_escape_string(stripslashes($_REQUEST['description_it']));
$description_es = mysql_real_escape_string(stripslashes($_REQUEST['description_es']));
$description_ru = mysql_real_escape_string(stripslashes($_REQUEST['description_ru']));
$description_zh = mysql_real_escape_string(stripslashes($_REQUEST['description_zh']));
$publish = mysql_real_escape_string(stripslashes($_REQUEST['publish']));	  
$priority = mysql_real_escape_string(stripslashes($_REQUEST['priority']));
$level = mysql_real_escape_string(stripslashes($_REQUEST['level']));	  
$parent = mysql_real_escape_string(stripslashes($_REQUEST['parent']));	  

			$sql1 = "SELECT * FROM infocategories ORDER BY id";
			$result1 = mysql_query($sql1);
	while ($myrow=mysql_fetch_array($result1)) {
			$pid=$myrow['id'];
}?>
<?php if ($pid=='') { 
$priorityid=1;
}
else {
$priorityid=$pid * 10;
}?>			

<?php 
if  (isset($_POST['submit'])) {
	
if ($parent!=0) {
$level='2';  
 }else{ 
 $level='1'; }
			
			$sql = "INSERT INTO infocategories (category, category_en, category_de, category_fr, category_it, category_es, category_ru, category_zh, description, description_en, description_de, description_fr, description_it, description_es, description_ru, description_zh, publish, priority, level, parent) VALUES ('$category', '$category_en', '$category_de', '$category_fr', '$category_it', '$category_es', '$category_ru', '$category_zh', '$description', '$description_en', '$description_de', '$description_fr', '$description_it', '$description_es', '$description_ru', '$description_zh', '$publish', '$priorityid', '$level', '$parent')";
			$result = mysql_query($sql);
?>

                  <?php
            $result10 = mysql_query("SELECT * FROM infocategories ORDER BY id desc LIMIT 1",$dbh);
			$myrow=mysql_fetch_array($result10); 
			$newid=$myrow['id'];
			
?>

                    <?php 
        $uploaddir = '../flash/info/'; 
		$uploadid = $newid; 
		$filetype = '.jpg'; 
		$uploadname = $newid . $filetype; 
		
if (isset($_POST['submit'])){ 
        if( $_FILES['upload']['tmp_name'] != "" ){
		
        $dest = $uploaddir . $uploadname; 
       if (copy ( $_FILES['upload']['tmp_name'], $dest )){ 
                } 
            else{ 
                $sql="UPDATE infocategories SET image='no' WHERE id='$newid'";
		        $result = mysql_query($sql);
            } }
?>
<?php } ?>    

<meta http-equiv="refresh" content="0;URL=new-infocategory.php">
<?php			
}
else  {
?>

<table width="980" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td><div><img src="img/frame-add.png" width="180" height="37" alt=""></div>
<div class="frame">
<form name="forma" method="post" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" enctype="multipart/form-data">
  <table width="100%" border="0" cellspacing="0" cellpadding="4" class="text">
    <tr>
      <td width="20">&nbsp;</td>
      <td width="200">Υποκατηγορία της</td>
      <td><select name="parent" class="forms">
        <?php 
			$sql = "SELECT * FROM infocategories WHERE level='1' ORDER BY priority";
			$result = mysql_query($sql);
	while ($myrow=mysql_fetch_array($result)) {
			$id=$myrow['id'];
			$category=$myrow['category'];
?>
        <?php 
			$sql2 = "SELECT * FROM rooms WHERE category_id='$id'";
			$result2 = mysql_query($sql2);
			$nu_row2 = mysql_num_rows($result2);
?>
        <?php 
	if  ( ( $nu_row2==0)) {
	?>
        <option value="<?php echo $id ?>"> <?php echo $category ?> </option>
        <?php } else { ?>
        <?php
 } }
?>
        <option value="0" selected>ΚΥΡΙΑ ΚΑΤΗΓΟΡΙΑ</option>
      </select></td>
    </tr>
     <?php if ($lang1==1) { ?>
    <tr>
      <td width="20"><img src="img/lang1.png" width="16" height="16" alt=""></td> 
      <td width="200">Τίτλος 
        </td>
      <td> 
        <input type="text" name="category" size="100" class="forms">
        </td>
    </tr>
    <?php } ?>
    <?php if ($lang2==1) { ?>
    <tr>
      <td><img src="img/lang2.png" width="16" height="16" alt=""></td> 
      <td>Τίτλος </td>
      <td> 
        <input type="text" name="category_en" size="100" class="forms">
        </td>
      </tr>
      <?php } ?>
    <?php if ($lang3==1) { ?>
    <tr>
      <td><img src="img/lang3.png" width="16" height="16" alt=""></td>
      <td>Τίτλος </td>
      <td><input type="text" name="category_de" size="100" class="forms"></td>
    </tr>
      <?php } ?>
    <?php if ($lang4==1) { ?>
    <tr>
      <td><img src="img/lang4.png" width="16" height="16" alt=""></td>
      <td>Τίτλος </td>
      <td><input type="text" name="category_fr" size="100" class="forms"></td>
    </tr>
      <?php } ?>
    <?php if ($lang5==1) { ?>
    <tr>
      <td><img src="img/lang5.png" width="16" height="16" alt=""></td>
      <td>Τίτλος </td>
      <td><input type="text" name="category_it" size="100" class="forms"></td>
    </tr>
      <?php } ?>
    <?php if ($lang6==1) { ?>
    <tr>
      <td><img src="img/lang6.png" width="16" height="16" alt=""></td>
      <td>Τίτλος </td>
      <td><input type="text" name="category_es" size="100" class="forms"></td>
    </tr>
      <?php } ?>
    <?php if ($lang7==1) { ?>
    <tr>
      <td><img src="img/lang7.png" width="16" height="16" alt=""></td>
      <td>Τίτλος </td>
      <td><input type="text" name="category_ru" size="100" class="forms"></td>
    </tr>
      <?php } ?>
      <?php if ($lang8==1) { ?>
    <tr>
      <td><img src="img/lang8.png" width="16" height="16" alt=""></td>
      <td>Τίτλος </td>
      <td><input type="text" name="category_zh" size="100" class="forms"></td>
    </tr>
      <?php } ?>
    <?php if ($lang1==1) { ?>
    <tr>
      <td><img src="img/lang1.png" width="16" height="16" alt=""></td> 
      <td>Περιγραφή </td>
      <td> 
        <textarea name="description" cols="100" rows="10" class="forms"></textarea>
        </td>
    </tr>
      <?php } ?>
    <?php if ($lang2==1) { ?>
    <tr>
      <td><img src="img/lang2.png" width="16" height="16" alt=""></td> 
      <td>Περιγραφή </td>
      <td> 
        <textarea name="description_en" cols="100" rows="10" class="forms"></textarea>
        </td>
      </tr>
      <?php } ?>
    <?php if ($lang3==1) { ?>
    <tr>
      <td><img src="img/lang3.png" width="16" height="16" alt=""></td>
      <td>Περιγραφή </td>
      <td><textarea name="description_de" cols="100" rows="10" class="forms"></textarea></td>
    </tr>
      <?php } ?>
    <?php if ($lang4==1) { ?>
    <tr>
      <td><img src="img/lang4.png" width="16" height="16" alt=""></td>
      <td>Περιγραφή </td>
      <td><textarea name="description_fr" cols="100" rows="10" class="forms"></textarea></td>
    </tr>
      <?php } ?>
    <?php if ($lang5==1) { ?>
    <tr>
      <td><img src="img/lang5.png" width="16" height="16" alt=""></td>
      <td>Περιγραφή </td>
      <td><textarea name="description_it" cols="100" rows="10" class="forms"></textarea></td>
    </tr>
      <?php } ?>
    <?php if ($lang6==1) { ?>
    <tr>
      <td><img src="img/lang6.png" width="16" height="16" alt=""></td>
      <td>Περιγραφή </td>
      <td><textarea name="description_es" cols="100" rows="10" class="forms"></textarea></td>
    </tr>
      <?php } ?>
    <?php if ($lang7==1) { ?>
    <tr>
      <td><img src="img/lang7.png" width="16" height="16" alt=""></td>
      <td>Περιγραφή </td>
      <td><textarea name="description_ru" cols="100" rows="10" class="forms"></textarea></td>
    </tr>
     <?php } ?>
     <?php if ($lang8==1) { ?>
    <tr>
      <td><img src="img/lang8.png" width="16" height="16" alt=""></td>
      <td>Περιγραφή </td>
      <td><textarea name="description_zh" cols="100" rows="10" class="forms"></textarea></td>
    </tr>
     <?php } ?>
    <tr>
      <td>&nbsp;</td>
      <td>Εικόνα</td>
      <td><input type="hidden" name="max_file_size" value="600000">
        <input name="upload" type="file" size="50" class="forms"></td>
    </tr>
    <tr>
      <td>&nbsp;</td> 
      <td>Δημοσίευση στο site?</td>
      <td><select name="publish" class="forms">
        <option value="yes" selected>yes</option>
        <option value="no">no</option>
        </select></td>
    </tr>
    </table>

  <div align="center" style="padding:5px">
   <input type="submit" name="submit" value="Καταχώρηση" class="button">
        <input type="reset" name="reset" value="Επαναφορά" class="button">  </div>
</form>  
</div>
<div align="right"><a href="all-infocategories.php" class="links">μεταφορά στην Λίστα</a></div></td>
  </tr>
</table><?php include 'menudown.php';?>
<?php } ?>
</body>
</html>