<?php
	require_once ('authorize1.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">

<head>
<title>Moreno Travel</title>
<script src="sorttable.js"></script>
    <link href="style.css" rel="stylesheet" type="text/css" />
    <meta http-equiv="content-type"
        content="text/html; charset=utf-8" />

<style>

tr.order { border-bottom: 1px solid }</style>

</head>




<?php include 'admin_header.php'; ?>

<h1>Manage hotel to price Assignments</h1>


<ul>


<i><font color="#C11B17" size="0.5px">Click <a href="admin_addhotel.php" target="blank">here</a> to add a new hotel.<br>
Click <a href="admin_updatehotelpricelink.php" target="blank">here</a> to add a new price to hotel assignment.<br><br>
</i></font>



<?php
require_once('connectvars.php');
$package_id = $_POST['package_id'];
$dbh = mysql_connect(hostname, username, password)

	or die("Unable to connect to MySQL");

mysql_select_db (dbname, $dbh);

$query = sprintf("SELECT package_name FROM packages WHERE package_id='$package_id'");

$result = mysql_query($query);



if (!$result) {

    $message  = 'Invalid query: ' . mysql_error() . "\n";

    $message .= 'Whole query: ' . $query;

    die($message);

}

while ($row = mysql_fetch_assoc($result)) {

echo "<h1>".$row['package_name']."</h1>";


}
?>



<table><tr><td width="300px"><b>Price </b></td><td width="300px"><b>Hotel</b></td></tr>


<?php
require_once('connectvars.php');
$package_id = $_POST['package_id'];
$dbh = mysql_connect(hostname, username, password)

	or die("Unable to connect to MySQL");

mysql_select_db (dbname, $dbh);

$result = mysql_query("SELECT * FROM hotelpricelink hp, hotel h, prices pr WHERE hp.hotel_id = h.hotel_id AND hp.price_id = pr.price_id AND package_id='$package_id' ORDER BY pr.price_id");

$i = 0;

print "<form name='managehotelpricelink' method='post' action='admin_updatehotelpricelink.php'>\n";

while ($hotelprice = mysql_fetch_array($result)) {

$hotelpricelink_id = $hotelprice['hotelprice_id'];
print "<tr><td><input type=\"hidden\" name=\"hotelpricelink_id[]\" value=\"$hotelpricelink_id\" ></td><td> "; 
?>
<select name="price_id[]"  />  <option value="disabled" >Select a Price:</option> 

 <?php

$dbh = mysql_connect(hostname, username, password)

	or die("Unable to connect to MySQL");

mysql_select_db (dbname, $dbh);



$query = sprintf("SELECT * FROM prices ORDER BY rating");




$resultp = mysql_query($query);


if (!$resultp) {

    $message  = 'Invalid query: ' . mysql_error() . "\n";

    $message .= 'Whole query: ' . $query;

    die($message);

}


while ($row = mysql_fetch_assoc($resultp)) {

if ($row['price_id']==$hotelprice['price_id']){$selected =  " selected=true ";} else {$selected = "";}
echo "<option value=\"".$row['price_id']. "\"". $selected . ">ID: ".$row['price_id']." - ".$row['season']." - Triple: ".$row['triplecost']." - Double: ".$row['doublecost']."
 - Single: ".$row['singlecost']." - Minor ".$row['minorcost']."</option>";

}
?>
</select><br><br><td>

<select name="hotel_id[]"  />  <option value="disabled" >Select a Hotel:</option> 

 <?php

$dbh = mysql_connect(hostname, username, password)

	or die("Unable to connect to MySQL");

mysql_select_db (dbname, $dbh);



$query = sprintf("SELECT hotel_name, hotel_id FROM hotel ORDER BY hotel_name ASC");




$resultc = mysql_query($query);


if (!$resultc) {

    $message  = 'Invalid query: ' . mysql_error() . "\n";

    $message .= 'Whole query: ' . $query;

    die($message);

}


while ($row = mysql_fetch_assoc($resultc)) {

if ($row['hotel_id']==$hotelprice['hotel_id']){$selected =  " selected=true ";} else {$selected = "";}
echo "<option value=\"".$row['hotel_id']. "\"". $selected . ">".$row['hotel_name']."</option>";






}
?>
</select><br><br>

</td></tr>

<?php

++$i;
}
print "<tr><td><input type='submit' value='submit' /></td></tr>";
print "</form>";
mysql_close();
?>



</table>
<br><br>




</ul><br><br><br>
</div>

</div>

</body>

</html>