Add Flight
<<Back to Main Menu
Description:
Processes an Add Flight Form to add Flight details to the database
Accessible by:
Managers
Accessed from:
Add Flight Form
Input parameters:
Route
Daily/Weekly/Monthly/One Off
Departure
Arrival
Starts On
Ends By
New/Existing Aircraft Type
Aircraft Type
Economy Seats
Business Seats
First Class Seats
Aircraft Type Name
Output
Success message with list of flights created and links to View Fligt
Add Flight Form and error message if there were errors in the form
Pseudo Code:
get/create session
if ('usertype' param in session == 'm') {
get form params
validate form
if (form params are in the correct format) {
if ('New/Existing Aircraft Type' param in the form == 'new') {
add the relevant data to the Aircraft Type table
get the id number of the type just inserted
}
else {
get the seating capacity of the Type selected
}
if ('Daily/Weekly/Monthly/One Off' == 'One Off') {
add the flight to the database
}
else {
Last Date Added = 'Starts On' param from the form
while('Last Date Added' < 'Ends By' param in form) {
add the Flight to the database with the date as 'Last Day Added'
if ('Daily/Weekly/Monthly/One Off' == 'Daily') {
increment 'Last Date Added' by one day
}
else if ('Daily/Weekly/Monthly/One Off' == 'Weekly') {
increment 'Last Date Added' by one week
}
else if ('Daily/Weekly/Monthly/One Off' == 'Monthly') {
increment 'Last Date Added' by one month
}
}
}
display success message with the details of each Flight added, with a link to View Flight
}
else {
display an Add Flight Form with an error message
}
}
else {
error message to say user must be a manager
}