View Flights

<<Back to Main Menu

Description:
This lists all the flights in the database, displaying 'from', 'to', 'operator', 'date', 'time'. Each has an associated link to View Flight (for more information). There are options to sort the list in various ways. If the list is sorted by number of seats sold/left or revenue earned, that relevant figure is also displayed.

Accessible by:
Managers

Accessed from:
Main Menu
Itself

Input parameters:
limit
sortBy

Output
List of flights with links to View Flight. This list is part of a View Flights Form, which allows the manager to order the search in various ways, by submitting the form to Itself
The options in the form are to sort by 'from', 'to', 'date' or 'operator'
Additionally, the manager can check the best and worst selling flights.
There is also an option just to display flights in the future, or just flights in the past

Pseudo Code:
get session
if ('usertype' param in the session == 'm') {
   get parameters from the form
   if ((there's no 'limit' param)OR('limit' param isn't 'before' or 'after')) {
      get flights data from the database
   }
   else if ('limit' == 'before') {
      get flights from the database which depart before the current time
   }
   else if ('limit' == 'after') {
      get flights from the database which depart after the current time
   }
   if (there's no 'sortBy' variable) {
      display the list in a View Flights Form
   }
   else if (sortBy == 'from') {
      sort the list by 'from'
      display the list in a View Flights Form
   }
   else if (sortBy == 'to') {
      sort the list by 'to'
      display the list in a View Flights Form
   }
   else if (sortBy == 'operator') {
      sort the list by 'op'
      display the list in a View Flights Form
   }
   else if (sortBy == 'dateTime') {
      sort the list by date and time
      display the list in a View Flights Form
   }
   else if (sortBy == 'mostBooked') {
      sort the list by the number of seats booked (highest to lowest)
      display the list in a View Flights Form
   }
   else if (sortBy is 'leastBooked') {
      sort the list by the number of seats booked (lowest to highest)
      display the list in a View Flights Form  
   }
   else if (sortBy == 'mostLeft') {
      sort the list by the number of seats available (hightest to lowest)
      display the list in a View Flights Form
   }
   else if (sortBy == 'leastLeft') {
      sort the list by the number of seats available (lowest to highest)
      display the list in a View Flights Form
   }   
   else if (sortBy == 'mostRev') {
      sort the list by the revenue earned by the flight (hightest to lowest)
      display the list in a View Flights Form
   }
   else if (sortBy == 'leastRev') {
      sort the list by the revenue earned by the flight (lowest to highest)
      display the list in a View Flights Form
   }
   else {
      display an error message and display the list unsorted in a View Flights Form
   }
}
else {
   error message to say user must be a manager
}