<!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 
$roomid = mysql_real_escape_string(stripslashes($_REQUEST['roomid']));
$room_id = mysql_real_escape_string(stripslashes($_REQUEST['room_id']));	  
$season_id = mysql_real_escape_string(stripslashes($_REQUEST['season_id']));
$price = mysql_real_escape_string(stripslashes($_REQUEST['price']));

if  (isset($_POST['submit'])) {
			$sql = "INSERT INTO prices (season_id, room_id, price) VALUES ('$season_id', '$roomid', '$price')";
			$result = mysql_query($sql);
?>
<?php 
			$sql1 = "SELECT * FROM seasons";
			$result1 = mysql_query($sql1);
			$nu_row1 = mysql_num_rows($result1);
?>
                       
                        <?php 
			$sql2 = "SELECT * FROM prices WHERE room_id='$roomid'";
			$result2 = mysql_query($sql2);
			$nu_row2 = mysql_num_rows($result2);
?>

                        <?php 
	if  ( ( $nu_row1==$nu_row2)) {
	?>
	<meta http-equiv="refresh" content="0;URL=all-rooms.php">

                        <?php } else {?>

<meta http-equiv="refresh" content="0;URL=new-price.php?roomid=<?php echo $roomid ?>">
<?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">Σεζόν              <input type="hidden" name="roomid" value="<?php echo $roomid ?>"></td>
            <td><select name="season_id" class="forms">
              <?php 
			

			$sql = "SELECT * FROM seasons ORDER BY id";
			$result = mysql_query($sql);
			while ($myrow=mysql_fetch_array($result)) {
				$seasonid=$myrow['id'];
				$season=$myrow['season'];
?>
              <?php 
             $nu_row = '0';
              $zero='0';
			
			$sql4 = "SELECT * FROM prices WHERE room_id='$roomid' AND season_id='$seasonid'";
			$result4 = mysql_query($sql4);
			$nu_row = mysql_num_rows($result4);
?>
              <?php 
	if  ( ( $nu_row==0)) {
	?>
              <option value="<?php echo $seasonid ?>"> <?php echo $season ?> </option>
              <?php } else {?>
              <?php }?>
              <?php }?>
            </select></td>
          </tr>
          <tr>
            <td>&nbsp;</td> 
            <td>Τιμή ΕΥΡΩ / διανυκτέρευση</td>
            <td><input type="text" name="price" size="30" class="forms"></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-prices.php?roomid=<?php echo $roomid ?>" class="links">μεταφορά στην Λίστα</a></div></td>
  </tr>
</table><?php include 'menudown.php';?>
<?php } ?>
</body>
</html>
