rendered paste body<?php
/* MYFLIGHTS.PHP - flight viewing system */
// Headers and Includes
//******************************************************************************
require_once("headers/header_dbfns.php");
require_once("headers/header_templatefns.php");
// Import Variables
//******************************************************************************
$DB = new dbControl("<CLIPPED>", "<CLIPPED>", "<CLIPPED>", "<CLIPPED>");
// Functions
//******************************************************************************
// Create the reservation table. If $old=True, then list reservations
// that have already passed.
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function createResTable ($old)
{
// Generate date condition
$old? $curDateTime = "<='" : $curDateTime = ">'" ;
// Format: 22 January 2006 4:30 PM
$curDateTime .= date('d F Y g\:i A\'');
$sql = "SELECT ReservationID, TotalPrice FROM Reservations NATURAL JOIN FlightReservations WHERE CustomerID=3";
$res = $DB->dbQuery($sql, __FILE__, __LINE__);
$table = "";
// Go through each reservation, and build the table
while($row = $res->fetchRow()) {
$resID = $row['ReservationID'];
$price = $row['TotalPrice'];
$sql=" SELECT SeatID FROM Seats NATURAL JOIN FlightDates NATURAL JOIN FlightSegments
WHERE ReservationID='" . $resID . "'
AND (DepartureDate + DepartureTime) " . $curDateTime;
echo $sql;
$table .= "<tr>";
}
return table;
}
// Page Generation
//******************************************************************************
if(isset($_GET['method'])) {
// Past Reservations
//~~~~~~~~~~~~~~~~~~~~~
if($_GET['method'] == "pastflights") {
/* Set Up Page */
$cssincludes[] = "myflights_container.css";
$PAGECLASS = & new Page($cssincludes);
$TMP = & new Template("templates/content/tmp_comingflights.php");
$table = createResTable(True);
/* Pass in Variables */
$TMP->set("method", "pastflights");
$TMP->set("resTable", $table);
/* Render It */
$PAGECLASS->set("content", $TMP);
$PAGECLASS->render("templates/layout/lo_main.php");
}
// Details Page for selected reservation
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if($_GET['method'] == "flightdetails") {
/* Set Up Page */
$cssincludes[] = "myflights_container.css";
$PAGECLASS = & new Page($cssincludes);
$TMP = & new Template("templates/content/tmp_comingflights.php");
/* Pass in Variables */
$TMP->set("method", "flightdetails");
/* Render It */
$PAGECLASS->set("content", $TMP);
$PAGECLASS->render("templates/layout/lo_main.php");
}
}
// Upcoming Reservations
//~~~~~~~~~~~~~~~~~~~~~~~~~~
else {
/* Set Up Page */
$cssincludes[] = "myflights_container.css";
$PAGECLASS = & new Page($cssincludes);
$TMP = & new Template("templates/content/tmp_comingflights.php");
$table = createResTable(False);
/* Pass in Variables */
$TMP->set("method", false);
$TMP->set("resTable", $table);
/* Render It */
$PAGECLASS->set("content", $TMP);
$PAGECLASS->render("templates/layout/lo_main.php");
}
// Cleanup
//******************************************************************************
$DB->dbClose();
?>