def get_menu_destinations(): ''' Lists destinations ''' destinations = Get_Data(3) destinations_printer = destinations.get_destinations() print("##################################################") for row in destinations_printer: for i in row: print("| {:17}: {:26} | ".format(i, row[i])) print("##################################################") print() input("Press ENTER to continue.. ") get_menu()
def get_menu(): ''' Reads a CSV file to list data ''' listing_menu.build_title() listing_menu.build_menu() print("") user_input = input("Choose an option: ") if user_input == "1": emplist = Get_Data(2) #2 is constant for Crew empprinter = emplist.get_emp_list() print("") print("##################################################") for row in empprinter: for i in row: print("| {:17}: {:26} | ".format(i, row[i])) print("##################################################") print() get_sub_menu() #List employees elif user_input == "2": get_menu_destinations() #List destinations elif user_input == "3": get_voyage() #List destinations elif user_input == "4": print("Not enough time.") first_menu() elif user_input == MAINMENU: first_menu() elif user_input == BACK: first_menu() else: print("Invalid input") get_menu()
def get_voyage(): ''' Lists voyages ''' voyage = Get_Data(6) voyage_printer = voyage.get_voyage() print("#############################################################") for row in voyage_printer: for i in row: print("| {:28}: {:26} | ".format(i, row[i])) print("#############################################################") print("") print("1. Get voyages in a certain week") print("2. Get voyages by day") print("") print(' [B]ack [M]ain_menu') user_input_sec = input("Choose an option: ") print("") if user_input_sec == "1": #Get voyages in a certain week date_temp = input("Enter a date: ") print("") date_checker = Get_Data(6, None, None, None, date_temp) date_checker_printer = date_checker.get_voyage_week() if date_checker_printer == False: print("Enginn flug í þessari viku") else: print( "#############################################################" ) for row in date_checker_printer: for i in row: print("| {:28}: {:26} | ".format(i, row[i])) print( "#############################################################" ) print() input("Press ENTER to continue.. ") get_voyage() elif user_input_sec == "2": #Get voyages by day date_temp = input("Enter a date: ") print("") date_checker = Get_Data(6, None, None, None, date_temp) date_checker_printer = date_checker.get_voyage_day() if date_checker_printer == False: print("Enginn flug í þessari viku") else: print( "#############################################################" ) for row in date_checker_printer: for i in row: print("| {:28}: {:26} | ".format(i, row[i])) print( "#############################################################" ) print() input("Press ENTER to continue.. ") get_voyage() elif user_input_sec == MAINMENU: first_menu() elif user_input_sec == BACK: get_menu()
def get_sub_menu(): ''' Selects how to list the employees ''' print("") print("1. Find employee") print("2. Show pilots") print("3. Show flight attendants") print("4. Show employees on shift") print("5. Show employees not on shift") print("6. Find pilots with certain licence") print("7. Find a work week for a certain employee") print("") print(' [B]ack [M]ain_menu') user_input_sec = input("Choose an option: ") print("") if user_input_sec == "1": #Finds a employee with a certain social security number ssn_temp = input("Enter SSN: ") print("") emp_spec = Get_Data(2, ssn_temp) emp_spec_printer = emp_spec.get_specific_emp() if emp_spec_printer == False: print("No employee with that SSN") else: print("##################################################") for row in emp_spec_printer: for i in row: print("| {:17}: {:26} | ".format(i, row[i])) print("##################################################") print() print() input("Press ENTER to continue.. ") get_sub_menu() elif user_input_sec == "2": #Lists pilots emp_pilots = Get_Data(2) emp_pilots_printer = emp_pilots.get_pilots() print("##################################################") for row in emp_pilots_printer: for i in row: print("| {:17}: {:26} | ".format(i, row[i])) print("##################################################") print() input("Press ENTER to continue.. ") get_sub_menu() elif user_input_sec == "3": #Lists flight attendants emp_cabin = Get_Data(2) emp_cabin_printer = emp_cabin.get_flightattendants() print("##################################################") for row in emp_cabin_printer: for i in row: print("| {:17}: {:26} | ".format(i, row[i])) print("##################################################") print() input("Press ENTER to continue.. ") get_sub_menu() elif user_input_sec == "4": #Lists who are currently working emp_working = Get_Data(2) emp_working_printer = emp_working.get_emp_working() print("##################################################") for row in emp_working_printer: for i in row: print("| {:17}: {:26} | ".format(i, row[i])) print("##################################################") print() input("Press ENTER to continue.. ") get_sub_menu() elif user_input_sec == "5": #List who are currently not working emp_notworking = Get_Data(2) emp_notworking_printer = emp_notworking.get_emp_not_working() print("##################################################") for row in emp_notworking_printer: for i in row: print("| {:17}: {:26} | ".format(i, row[i])) print("##################################################") print() input("Press ENTER to continue.. ") get_sub_menu() elif user_input_sec == "6": #Lists pilots with that type of licence licence_temp = input("Enter aircraft type: ") print("") pilots_licence = Get_Data(2, None, licence_temp) pilots_licence_printer = pilots_licence.get_pilots_from_airtype() if pilots_licence_printer == False: print("No pilot with that perticular licence") else: print("##################################################") for row in pilots_licence_printer: for i in row: print("| {:17}: {:26} | ".format(i, row[i])) print("##################################################") print() input("Press ENTER to continue.. ") get_sub_menu() elif user_input_sec == "7": #Lists all voyages flown by a certain employee by week name_of_temp = input("Enter name of employee: ") date_temp = input("Enter a date: ") print("") date_checker = Get_Data(6, None, None, name_of_temp, date_temp) date_checker_printer = date_checker.get_voyage_emp_week() if date_checker_printer == False: print("No flights listed in this ") else: print( "#############################################################" ) for row in date_checker_printer: for i in row: print("| {:28}: {:26} | ".format(i, row[i])) print( "#############################################################" ) print() input("Press ENTER to continue.. ") get_sub_menu() elif user_input_sec == MAINMENU: first_menu() elif user_input_sec == BACK: get_menu() elif user_input_sec == MAINMENU: first_menu() elif user_input_sec == BACK: get_menu()
def New_voyage(): ''' Creates a new voyage ''' flown_tday = True destination = input("Destination: ") if destination == CANCEL: first_menu() return date_from_iceland = input("Date From Iceland: ") if date_from_iceland == CANCEL: first_menu() return date_back_from_iceland = input("Date Back To Iceland: ") if date_back_from_iceland == CANCEL: first_menu() return while flown_tday: pilot_captain = input("Captain: ") if pilot_captain == CANCEL: first_menu() return checker = Get_Data(6, None, None, pilot_captain, date_from_iceland, 1) #Checks if the pilot has already flown today flown_tday = checker.get_checker() if flown_tday == True: print("Employee has already flown today. Choose another.") flown_tday = True while flown_tday: pilot_copilot = input("CoPilot: ") if pilot_copilot == CANCEL: first_menu() return checker = Get_Data(6, None, None, pilot_copilot, date_from_iceland, 2) #Checks if the pilot has already flown today flown_tday = checker.get_checker() if flown_tday == True: print("Employee has already flown today. Choose another.") flown_tday = True while flown_tday: flight_attendant_supervisor = input("Flight Attendant Supervisor: ") if flight_attendant_supervisor == CANCEL: first_menu() return checker = Get_Data(6, None, None, flight_attendant_supervisor, date_from_iceland, 3) #Checks if the flight attendant has already flown today flown_tday = checker.get_checker() if flown_tday == True: print("Employee has already flown today. Choose another.") flown_tday = True while flown_tday: flight_attendant = input("Flight Attendant: ") if flight_attendant == CANCEL: first_menu() return checker = Get_Data(6, None, None, flight_attendant, date_from_iceland, 4) #Checks if the flight attendant has already flown today flown_tday = checker.get_checker() if flown_tday == True: print("Employee has already flown today. Choose another.") new_voy = Voyage(date_from_iceland, destination, date_back_from_iceland, pilot_captain, pilot_copilot, flight_attendant_supervisor, flight_attendant) new_voy.store_voyage() Reg_menu()
def update_voyage(): ''' Updates excisting data on voyages ''' date_from_iceland = input("Enter date of voyage (YYYY-MM-DDThh:mm:ss): ") find_voyage = Get_Data(6, None, None, None, date_from_iceland) voyage_printer = find_voyage.get_voyage_day() new_dict = {} #Converting a list to a dict to handle the updates for item in voyage_printer: name = item.pop('date_from_iceland') new_dict[name] = item if voyage_printer == False: print("No flights listed on this date!") elif date_from_iceland == CANCEL: first_menu() return else: print("#############################################################") for row in voyage_printer: for i in row: print("| {:28}: {:26} | ".format(i, row[i])) print( "#############################################################" ) print() print() what_voy_update = input("What information to change: ") pilot_captain = "" pilot_copilot = "" flight_attendant_supervisor = "" flight_attendant = "" if what_voy_update == "pilot_captain": pilot_captain = input("Pilot captain: ") if pilot_captain == CANCEL: first_menu() return else: pilot_captain = item["pilot_captain"] if what_voy_update == "pilot_copilot": pilot_copilot = input("pilot_copilot: ") if pilot_copilot == CANCEL: first_menu() return else: pilot_copilot = item["pilot_copilot"] if what_voy_update == "flight_attendant_supervisor": flight_attendant_supervisor = input("Flight attendant supervisor: ") if flight_attendant_supervisor == CANCEL: first_menu() return else: flight_attendant_supervisor = item["flight_attendant_supervisor"] if what_voy_update == "flight_attendant": flight_attendant = input("Flight attendant: ") if flight_attendant == CANCEL: first_menu() return else: flight_attendant = item["flight_attendant"] destination = item["destination"] date_back_to_iceland = item["date_back_to_iceland"] new_voy = Voyage(date_from_iceland, destination, date_back_to_iceland, pilot_captain, pilot_copilot, flight_attendant_supervisor, flight_attendant) new_voy.update_voyage() first_menu()
def update_employee_menu(): ''' Updates a already existing data found in various CSV files ''' ssn = input("Enter employee SSN: ") find_employee = Get_Data(2, ssn) employee_printer = find_employee.get_specific_emp() new_dict = {} #make list to a dict for item in employee_printer: name = item.pop('ssn') new_dict[name] = item if employee_printer == False: print("No employee with that SSN") elif ssn == CANCEL: first_menu() return else: print("##################################################") for row in employee_printer: for i in row: print("| {:17}: {:26} | ".format(i, row[i])) print("##################################################") print() print() what_emp_update = input("What information to change: ") role = "" rank = "" licence = "" mobile = "" address = "" if what_emp_update == "role": role = input("Role: ") if role == CANCEL: first_menu() return else: role = item["role"] if what_emp_update == "rank": rank = input("Rank: ") if rank == CANCEL: first_menu() return else: rank = item["rank"] if what_emp_update == "licence": licence = input("Licence: ") if licence == CANCEL: first_menu() return else: licence = item["licence"] if what_emp_update == "address": address = input("Address: ") if address == CANCEL: first_menu() return else: address = item["address"] if what_emp_update == "mobile": mobile = input("mobile: ") if mobile == CANCEL: first_menu() return else: mobile = item["mobile"] firstname = item["firstname"] lastname = item["lastname"] new_emp = Employee(ssn, firstname, lastname, role, rank, licence, address, mobile) new_emp.update_employee() first_menu()