Booking

<<Back to Main Menu

Description:
Processes the Booking Form to add the booking in the database.

Accessible by:
Customers and Managers

Accessed from:
Booking Form

Input parameters:
Return/Single
Flight Numbers
Adult Passengers
Class
Child Passengers
Passenger Names
Card ID
CardHolder Name
Card Number
Card Expiry

Output
Flight details with a confirmation number (session ID).

Pseudo Code:
get/create session
if ('username' param exists in the session) {
   if (there's a 'Booking' param in the session) { //user had to login or register
      get the Booking details from the session
      get the params from the form
      validate form
      if (form params are in the correct format) {
         for each flight booked {
            if (there are not enough seats on the flight to match the order) { //in case someone else has booked them since this user selected the flights
               display an error message and don't continue any further
            }
         }
         for each flight booked {
            add an entry to the 'bookings' table
         }
         get the booking ID from the entry and display to the screen as the user's confirmation number
         insert the passenger names into the 'passengers' table
         if (the user has used loyalty points in the booking) {
            update the 'users' table to reduce the number of loyalty points the user has
         }
         else {
            update the 'users' table to increase the number of loyalty points the user has
         }
         update the 'flights' table to increase the number of seats of each class sold
         display flight itinerary
      }
      else {
         display Booking Form with an error message.
      }
   }
   else {
      display an error message
   }
}
else {
   display error message that user must be logged in
}