<?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'; ?>

<div id="main2">
<h1>Moreno Travel Admin Portal</h1>




<i><font color="#C11B17" size="0.5px">
Click <a href="admin_addpackage.php" target="blank">here</a> to add a new package.<br>
Click <a href="admin_addextension.php" target="blank">here</a> to add a new package extension assignment.<br><br>
</i></font>

<p>Manage extensions as required:</p>

<table><tr><th><b>Primary Package</b></th><th><b>Secondary Package</b></th></tr>
<?php
require_once('connectvars.php');

$dbh = mysql_connect(hostname, username, password)

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

mysql_select_db (dbname, $dbh);

$result = mysql_query("SELECT * FROM extendtrip");

$i = 0;

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

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

print "<tr><td><input type='hidden' size='3' name='extendtrip_id[$i]' value='{$extend['extendtrip_id']}' />";
//print "<input type='text' size='40' name='primarypackage_id[$i]' value='{$extend['primarypackage_id']}' /></td>";
//print "<td><input type='text' size='40' name='extendedpackage_id[$i]' value='{$extend['extendedpackage_id']}' /></td>";
?>
<tr><td><select name="primarypackage_id[]"  />  <option value="disabled" >Select a Package:</option> 

 <?php

$dbh = mysql_connect(hostname, username, password)

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

mysql_select_db (dbname, $dbh);



$query = sprintf("SELECT package_name, package_id FROM packages ORDER BY package_name ASC");




$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['package_id']==$extend['primarypackage_id']){$selected =  " selected=true ";} else {$selected = "";}
echo "<option value=\"".$row['package_id']. "\"". $selected . ">".$row['package_name']."</option>";

}
?>
</select></td>

<td><select name="extendedpackage_id[]"  />  <option value="disabled" >Select a Package:</option> 

 <?php

$dbh = mysql_connect(hostname, username, password)

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

mysql_select_db (dbname, $dbh);



$query = sprintf("SELECT package_name, package_id FROM packages ORDER BY package_name ASC");




$resulta = mysql_query($query);


if (!$resulta) {

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

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

    die($message);

}


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

if ($row['package_id']==$extend['extendedpackage_id']){$selected =  " selected=true ";} else {$selected = "";}
echo "<option value=\"".$row['package_id']. "\"". $selected . ">".$row['package_name']."</option>";

}
?>
</select></td></tr>

<?php
++$i;
}

mysql_close();
?>

</tr></table>

<br><input type='submit' value='submit' /></form>

<br><br>




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

<?php include 'footer.php'; ?>
</div>

</body>

</html>