<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';
			$sql10 = "SELECT * FROM photos ORDER BY id";
			$result10 = mysql_query($sql10);
	while ($myrow=mysql_fetch_array($result10)) {
			$pid=$myrow['id'];
			
			$priorityid=$pid * 10;
}?>

 <?php 
if ($submit) {
			include 'connect.php';
			$sql = "INSERT INTO photos (category_id, room_id, main, name, name_en, name_de, description, description_en, description_de, promote, priority) VALUES ('$category_id', '$room_id', '$main', '$name', '$name_en', '$name_de', '$description', '$description_en', '$description_de', '$promote', '$priorityid')";
			$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">PHOTO ΠΡΟΣΤΕΘΗΚΕ</div>
    </td>
  </tr>
  <tr> 
    <td bordercolor="#FFFFFF">&nbsp;</td>
  </tr>
  <tr> 
    <td bordercolor="#FFFFFF"> 
      <div align="center"><b> 
        <?php echo $name   ?>
        </b> </div>
    </td>
  </tr>
  <tr> 
    <td bordercolor="#FFFFFF">&nbsp; </td>
  </tr>
</table>
<meta http-equiv="refresh" content="0;URL=new-photo.php">
<?php			
}
else  {
?>
<form name="forma" method="post" action="">
  <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">ΠΡΟΣΘΗΚΗ PHOTO</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%">Ενότητα</td>
            <td> 
              <select name="category_id" class="forms">
                <option value="0" selected>ΚΑΜΙΑ</option>
                <?php 
			include 'connect.php';
			$sql9 = "SELECT * FROM photocategories ORDER BY priority";
			$result9 = mysql_query($sql9);
			while ($myrow=mysql_fetch_array($result9)) {
				$category_id=$myrow['id'];
				$category=$myrow['category'];
?>
                <option value="<?php echo $category_id ?>"> 
                <?php echo $category ?>
                </option>
                <?php			
	}
?>
              </select>
            </td>
          </tr>
          <tr> 
            <td width="30%">Δωμάτιο</td>
            <td> 
              <select name="room_id" class="forms">
                <option value="0" selected>ΚΑΝΕΝΑ</option>
                <?php 
			include 'connect.php';
			$sql1 = "SELECT * FROM rooms ORDER BY priority";
			$result1 = mysql_query($sql1);
			while ($myrow=mysql_fetch_array($result1)) {
				$room_id=$myrow['id'];
				$room=$myrow['name'];
?>
                <option value="<?php echo $room_id ?>"> 
                <?php echo $room ?>
                </option>
                <?php			
	}
?>
              </select>
            </td>
          </tr>
          <tr> 
            <td width="30%">Προβολή στο κεντρικό Photo gallery?</td>
            <td> 
              <select name="main" class="forms">
                <option value="yes" selected>yes</option>
                <option value="no">no</option>
              </select>
            </td>
          </tr>
          <tr> 
            <td width="30%">Τίτλος - ελληνικά*</td>
            <td> 
              <input type="text" name="name" size="60" class="forms">
            </td>
          </tr>
          <tr> 
            <td width="30%">Τίτλος - αγγλικά*</td>
            <td> 
              <input type="text" name="name_en" size="60" class="forms">
            </td>
          </tr>
          <tr> 
            <td width="30%">Τίτλος - γερμανικά</td>
            <td> 
              <input type="text" name="name_de" size="60" class="forms" value="">
            </td>
          </tr>
          <tr> 
            <td width="30%">Περιγραφή - ελληνικά</td>
            <td> 
              <textarea name="description" cols="60" class="forms" rows="4"></textarea>
            </td>
          </tr>
          <tr> 
            <td width="30%">Περιγραφή - αγγλικά</td>
            <td> 
              <textarea name="description_en" cols="60" class="forms" rows="4"></textarea>
            </td>
          </tr>
          <tr> 
            <td width="30%">Περιγραφή - γερμανικά</td>
            <td> 
              <textarea name="description_de" cols="60" class="forms" rows="4"></textarea>
            </td>
          </tr>
          <tr> 
            <td width="30%">Προώθηση?</td>
            <td> 
              <select name="promote" class="forms">
                <option value="yes">yes</option>
                <option value="no" selected>no</option>
              </select>
            </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('name','','R','name_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>
