Cheapest Flights

<<Back to Main Menu

Description:
Searches for AerWeb flights only in the database. The user has specified that they'd like to either go one-way, or return after a specified number of days.
If it's a one-way trip, this servlet will return the five cheapest fare over the next two months.
If it's a return trip, it will return the five cheapest combinations of outgoing and return flights with the required number of days between them where the outgoing flight is during the next two months.

Accessible by:
Customers and Managers

Accessed from:
Cheapest Flights Form

Input parameters:
Return/Single
From
To
adults
children
Days

Output
Cheapest Flights Form if there are errors.
Display cheapest five flights from next two months if user has selected a one-way trip.
Display cheapest five combinations starting in the next two months if user has selected return trip.
Each flight has a link to View Flight for managers

Pseudo Code:
get/create session
if ('username' param exists in the session) {
   get params from the form
   validate form
   if (params are in the correct format) {
      save search params to the 'searches' table // for user profiling
      if ('return/single' param from form == 'single') {
         check that the selected Route exists 
         if (that route exists) {
            get the Flights serving that Route for the next two months, ordered by the economy price
            display the top five returned with radio buttons in a Select Flight Form
         }
         else {
            give an error message
         }
      }
      else if ('return/single' param from form == 'return') {
         if ((outward Route exists) AND (return Route exists)) {
            get the Flights serving the outward route for the next two months
            for each flight {
               get all the Flights serving the return route 'Days' days after the outward Flight
               get the cost of each combination
            }
            display the top five combinations with radio buttons in a Select Flight Form
         }
         else {
            display error message
         }
      }
   }
}
else {
   display error message that user must be logged in
}