<!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>
<?php 
$id = mysql_real_escape_string(stripslashes($_REQUEST['id']));
$page = mysql_real_escape_string(stripslashes($_REQUEST['page']));
$title = mysql_real_escape_string(stripslashes($_REQUEST['title']));
$description = mysql_real_escape_string(stripslashes($_REQUEST['description']));
$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 WHERE lang_id=1 ORDER BY id";
$result1 = mysql_query($sql1);
while ($myrow=mysql_fetch_array($result1)) {
$pid=$myrow['insert_id'];
			
}?>
<?php if ($pid=='') { 
$insertid=1;
$priorityid=10;
}
else {
$insertid=$pid + 1;
$priorityid=($pid + 1) * 10;
}?>

<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="3">
    <tr>
      <td width="20">&nbsp;</td>
      <td width="200">&gt;&gt;</td>
      <td>
        <select name="parent" class="forms">
          <?php 
			$sql1 = "SELECT * FROM infocategories WHERE level=1 AND lang_id=1 ORDER BY priority";
			$result1 = mysql_query($sql1);
	while ($myrow=mysql_fetch_array($result1)) {
			$catid=$myrow['insert_id'];
			$category=$myrow['title'];
?>
          <?php 
			$sql2 = "SELECT * FROM rooms WHERE category_id='$catid'";
			$result2 = mysql_query($sql2);
			$nu_row2 = mysql_num_rows($result2);
?>
          <?php if  ($nu_row2==0) { ?>
          <option value="<?php echo $catid ?>"> <?php echo $category ?> </option>
          <?php } else { ?>
          <?php
 } }
?>
          <option value="0" selected>ΚΥΡΙΑ ΚΑΤΗΓΟΡΙΑ</option>
          </select>
        </td>
    </tr>
    
    </table>
    
<?php
$sql50 = "SELECT * FROM lang WHERE active=1 ORDER BY id";
$result50 = mysql_query($sql50);
while ($myrow=mysql_fetch_array($result50)) {
$langid=$myrow['id'];
$language=$myrow['language'];
$dir=$myrow['dir'];
?>

<?php 
if  (isset($_POST['submit'])) {
	
if ($parent!=0) {
$level='2';  
}else{ 
$level='1'; }

$titlelang = $_REQUEST["title$langid"];
$descriptionlang = $_REQUEST["description$langid"];
$keywordslang = $_REQUEST["keywords$langid"];

$sql = "INSERT INTO infocategories (insert_id, lang_id, page, title, description, keywords, publish, priority, level, parent) VALUES ('$insertid', '$langid', '$page', '$titlelang', '$descriptionlang', '$keywordslang', '$publish', '$priorityid', '$level', '$parent')";
$result = mysql_query($sql);
} ?>

  <table width="100%" border="0" cellspacing="0" cellpadding="4">
    <tr>
      <td width="20"><img src="img/<?php echo $dir ?>.png" width="16" height="16" alt=""></td> 
      <td width="200">Τίτλος 
        </td>
      <td> 
        <input type="text" name="title<?php echo $langid ?>" size="100" class="forms">
        </td>
    </tr>
    <tr>
      <td><img src="img/<?php echo $dir ?>.png" width="16" height="16" alt=""></td>
      <td>Περιγραφή </td>
      <td><textarea name="description<?php echo $langid ?>" cols="100" rows="5" class="forms"></textarea></td>
    </tr>
    <tr>
      <td><img src="img/<?php echo $dir ?>.png" width="16" height="16" alt=""></td>
      <td>Keywords </td>
      <td><textarea name="keywords<?php echo $langid ?>" cols="100" rows="5" class="forms"></textarea></td>
    </tr>
    </table>

<?php } ?>

<table width="100%" border="0" cellspacing="0" cellpadding="4">
<tr>
      <td>&nbsp;</td>
      <td>Page</td>
      <td><input type="text" name="page" size="100" class="forms"></td>
    </tr>
    <tr>
      <td width="20">&nbsp;</td> 
      <td width="200">Εικόνα</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>
 
 <?php
       $result10 = mysql_query("SELECT * FROM infocategories WHERE lang_id=1 ORDER BY id desc LIMIT 1",$dbh);
	   $myrow=mysql_fetch_array($result10); 
	   $uploadid=$myrow['insert_id'];

        $uploaddir = '../flash/info/'; 
		$filetype = '.jpg';
		$uploadname = $uploadid . $filetype; 


if (isset($_POST['submit'])){ 
       if( $_FILES['upload']['tmp_name'] != "" ){
		
        $dest = $uploaddir . $uploadname; 
       if (copy ( $_FILES['upload']['tmp_name'], $dest )){ 

  $sql="UPDATE infocategories SET image='yes' WHERE insert_id='$uploadid'";
  $result = mysql_query($sql);         
 } } 
 
 }?>
   
  <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';?>

</body>
</html>
