def changeEmployeeInfo(self): ''' change employee information ''' input_name = input('Full name: ').title() emp_info_list = LL_Employee().getOneEmployeeName(input_name) if len(emp_info_list) == 0: print(":: No user with that name ::") else: for elem in emp_info_list: ssn = elem.ssn name = input_name firstname = input_name.split() role = input('Role: ') rank = input('Rank: ') pilot_license = input('Pilot license: ') address = input('Address: ') try: phone = int(input('Phone: ')) except ValueError: print("\n:: Invalid phone ::\n") phone = input('Phone: ') email = firstname[0] + "@nan.is" employee = Model_Employee(ssn, name, role, rank, pilot_license, address, phone, email) LL_Employee().change_Employee(employee) print("\n:: Information on {} has been updated ::".format(input_name))
def listCabinCrew(self): ''' prints all cabin crew ''' cabin_list = LL_Employee().get_Cabin() print("{:^44}".format('All cabin crew members')) print("."*44) print() for name, rank in cabin_list.items(): print(name, '-', rank)
def listPilots(self): ''' prints all pilots ''' pilot_list = LL_Employee().get_Pilots() print("{:^44}".format('All pilots')) print("."*44) print() for name, rank in pilot_list.items(): print(name, '-', rank)
def list_pilots_for_planetypeID(self): '''Prints all pilots with license on each plane type''' pilotlisence_dict = LL_Employee().listPilots_planetype() for plane, pilots in pilotlisence_dict.items(): print('\n\n{:^44}'.format(plane)) print('.'*44) print() for name, rank in pilots.items(): print('{} - {}'.format(name, rank))
def listEmployeesVoyagesInSpecificWeek(self): ''' prints a list of employyes voyages in specific week ''' name = input("Full name: ").title() usersWithName = LL_Employee().getOneEmployeeName(name) if len(usersWithName) == 0: print(":: No user with that name ::") else: for elem in usersWithName: ssn = elem.ssn print("From") print("----") from_year_input = input("Year: ") from_year = LL_Employee().checkIfValidDate(from_year_input) if from_year == None: print(":: Not a valid year ::") else: from_month_input = input("Month: ") from_month = LL_Employee().checkIfValidDate(from_month_input) if from_month == None: print(":: Not a valid month ::") else: from_day_input = input("Day: ") from_day = LL_Employee().checkIfValidDate(from_day_input) if from_day == None: print(":: Not a valid day ::") else: print("\nTo") print("----") to_year_input = input("Year: ") to_year = LL_Employee().checkIfValidDate(to_year_input) if to_year == None: print(":: Not a valid year ::") else: to_month_input = input("Month: ") to_month = LL_Employee().checkIfValidDate(to_month_input) if to_month == None: print(":: Not a valid month ::") else: to_day_input = input("Day: ") to_day = LL_Employee().checkIfValidDate(to_day_input) if to_day == None: print(":: Not a valid day ::") else: print() from_date = datetime.datetime(from_year, from_month, from_day, 0, 0, 0).isoformat() to_date = datetime.datetime(to_year, to_month, to_day+1, 0, 0, 0).isoformat() result = LL_Voyages().Week_Time(from_date, to_date) employee_list = LL_Employee().EmployeesVoyagesInSpecificWeek(ssn, result) for voyage in employee_list: print('{:>22} {} {:<22}'.format(voyage.flightOut.flightNumber, '-', voyage.flightBack.flightNumber)) print('.'*44,'\n') print('{}-{}: \n\t{} \n\t{}'.format(voyage.flightOut.departingFrom, voyage.flightOut.arrivingAt, voyage.flightOut.departure, voyage.flightOut.arrival)) print('{}-{}: \n\t{} \n\t{}'.format(voyage.flightBack.departingFrom, voyage.flightBack.arrivingAt, voyage.flightBack.departure, voyage.flightBack.arrival)) print('Crew: \n\tCaptain: {} \n\tCopilot: {} \n\tfsm: {} \n\tfa1: {} \n\tfa2: {}'.format(voyage.captain, voyage.copilot, voyage.fsm, voyage.fa1, voyage.fa2)) print()
def listEmployee(self): ''' prints all employees ''' result = LL_Employee().get_crew_list() print("{:^44}".format('All crew members')) print("."*44) print() for crewMember in result: print(crewMember.name, '-',crewMember.rank)
def listByName(self): '''prints all employees by name ''' name_input = input("Full name: ").title() usersWithName = LL_Employee().getOneEmployeeName(name_input) if len(usersWithName) == 0: print("no user with that name") else: for elem in usersWithName: print("\n\tName: {} \n\tSsn: {} \n\tRole: {} \n\tRank: {} \n\tLicense: {} \n\tAddress: {} \n\tPhone number: {} \n\tEmail: {}".format(elem.name, elem.ssn, elem.role, elem.rank, elem.license, elem.address, elem.phonenumber, elem.email))
def SetPilot(self): ''' set new pilot ''' ssn = input('Social security number: ') valid_ssn = LL_Employee().checkIfValidssn(ssn) if valid_ssn == None: print(":: Not a valid social security number ::") else: ssn = valid_ssn name = input('Full name: ').title() firstname = name.split() role = 'Pilot' print("1: Captain") print("2: Copilot") rank_input = input('Rank: ') if rank_input == 1: rank = "Captain" elif rank_input == 2: rank = "Copilot" planetypeID_list = LL_Aircrafts().planetypeID_list() for num, elem in enumerate(planetypeID_list): print(num+1, ': ', elem) pilotlicense_inp = input('Pilot license: ') if pilotlicense_inp == elem: pilot_license = pilotlicense_inp[pilotlicense_inp-1] address = input('Address: ') try: phone = int(input('Phone: ')) except ValueError: print("\n:: Invalid phone ::\n") phone = input('Phone: ') email = firstname[0] + "@nan.is" employee = Model_Employee(ssn, name, role, rank, pilot_license, address, phone, email) LL_Employee().createEmployee(employee) print("\n:: {} has been added as a Pilot ::".format(name))
def listByLicense(self): '''prints all employees by license ''' license_input = input("Pilot License: ").upper() usersWithLicense = LL_Employee().getOneEmployeeLicense(license_input) if len(usersWithLicense) == 0: print("Not a valid license") else: print() for elem in usersWithLicense: print('\t', elem.name, '-', elem.rank)
def listAircraftTypes(self): ''' prints all aircraft types ''' aircraftType_list = LL_Aircrafts().get_aircraftType_list( ) # listi af aircraft Types aircraft_list = LL_Aircrafts().get_aircrafts_list( ) # listi af aircrafts voyage = self.AircraftStatus(aircraft_list) pilot_count = LL_Employee().get_pilot_count() print() for aircraftType in aircraftType_list: print("{:^44}".format(aircraftType.planeTypeId)) print("." * 44) print( "\nName: {} \nManufacturer: {} \nModel: {} \nCapacity: {} \nEmpty weight: {} \nMax takeoff weight: {} \nUnit thrust: {} \nService ceiling: {} \nLength: {} \nHeight: {} \nWingspan: {}" .format(aircraftType.name, aircraftType.manufacturer, aircraftType.model, aircraftType.capacity, aircraftType.emptyWeight, aircraftType.maxTakeoffWeight, aircraftType.unitThrust, aircraftType.serviceCeiling, aircraftType.length, aircraftType.height, aircraftType.wingspan)) if aircraftType.planeTypeId in pilot_count.keys(): for planeID, count in pilot_count.items(): if planeID == aircraftType.planeTypeId: print('Pilots with license: {}'.format(count)) else: print('Pilots with license: {}'.format('0')) for line in aircraft_list: #line.planeTypeId.strip() if line.planeTypeId.strip() == aircraftType.planeTypeId: for elem in voyage: if elem.flightOut.aircraftID == line.planeInsignia: print() print("{:^44}".format("Aircraft is active")) print() print("Flight number:", elem.flightOut.flightNumber) print("Destination:", elem.flightOut.arrivingAt) print('Next available time:', elem.flightBack.arrival) print()
def listByWeekFilter(self): ''' prints all voyages in a specific week ''' print("From") print("----") from_year_input = input("Year: ") from_year = LL_Employee().checkIfValidDate(from_year_input) if from_year == None: print("\n:: Not a valid year ::") else: from_month_input = input("Month: ") from_month = LL_Employee().checkIfValidDate(from_month_input) if from_month == None: print("\n:: Not a valid month ::") else: from_day_input = input("Day: ") from_day = LL_Employee().checkIfValidDate(from_day_input) if from_day == None: print("\n:: Not a valid day ::") else: print("\nTo") print("----") to_year_input = input("Year: ") to_year = LL_Employee().checkIfValidDate(to_year_input) if to_year == None: print("\n:: Not a valid year ::") else: to_month_input = input("Month: ") to_month = LL_Employee().checkIfValidDate(to_month_input) if to_month == None: print("\n:: Not a valid month ::") else: to_day_input = input("Day: ") to_day = LL_Employee().checkIfValidDate(to_day_input) if to_day == None: print("\n:: Not a valid day ::") else: print() from_date = datetime.datetime(from_year, from_month, from_day, 0, 0, 0).isoformat() to_date = datetime.datetime(to_year, to_month, to_day+1, 0, 0, 0).isoformat() result = LL_Voyages().Week_Time(from_date, to_date) print() if len(result) == 0: print(":: No Voyage on selected date ::") else: for voyage in result: status_now = self.VoyageStatusNow(voyage) crew_status = self.VoyageCrewStatus(voyage) print('{:>22} {} {:<22}'.format(voyage.flightOut.flightNumber, '-', voyage.flightBack.flightNumber)) print('.'*44,'\n') print('{}-{}: \n\t{} \n\t{}'.format(voyage.flightOut.departingFrom, voyage.flightOut.arrivingAt, voyage.flightOut.departure, voyage.flightOut.arrival)) print() print('{}-{}: \n\t{} \n\t{}'.format(voyage.flightBack.departingFrom, voyage.flightBack.arrivingAt, voyage.flightBack.departure, voyage.flightBack.arrival)) if crew_status == True: print('Crew: \n\tCaptain: {} \n\tCopilot: {} \n\tfsm: {} \n\tfa1: {} \n\tfa2: {}'.format(voyage.captain, voyage.copilot, voyage.fsm, voyage.fa1, voyage.fa2)) else: print() print(crew_status) print('\nStatus: \n\t{}'.format(status_now)) print()
def listByDateFilter(self): ''' prints all voyages on a specific day ''' year_input = input("Year: ") year = LL_Employee().checkIfValidDate(year_input) if year == None: print("\n:: Not a valid year::") else: month_input = input("Month: ") month = LL_Employee().checkIfValidDate(month_input) if month == None: print("\n:: Not a valid month ::") else: day_input = input("Day: ") day = LL_Employee().checkIfValidDate(day_input) if day == None: print("\n:: Not a valid day ::") else: print() date_time = datetime.datetime(year, month, day, 0, 0, 0).isoformat() result = LL_Voyages().Date_Time(date_time) print() if len(result) == 0: print(":: No Voyage on selected date ::") else: for voyage in result: status_now = self.VoyageStatusNow(voyage) crew_status = self.VoyageCrewStatus(voyage) print('{:>22} {} {:<22}'.format(voyage.flightOut.flightNumber, '-', voyage.flightBack.flightNumber)) print('.'*44,'\n') print('{}-{}: \n\t{} \n\t{}'.format(voyage.flightOut.departingFrom, voyage.flightOut.arrivingAt, voyage.flightOut.departure, voyage.flightOut.arrival)) print() print('{}-{}: \n\t{} \n\t{}'.format(voyage.flightBack.departingFrom, voyage.flightBack.arrivingAt, voyage.flightBack.departure, voyage.flightBack.arrival)) if crew_status == True: print('Crew: \n\tCaptain: {} \n\tCopilot: {} \n\tfsm: {} \n\tfa1: {} \n\tfa2: {}'.format(voyage.captain, voyage.copilot, voyage.fsm, voyage.fa1, voyage.fa2)) else: print() print(crew_status) print('\nStatus: \n\t{}'.format(status_now)) print()
def listAllEmployeesNotWorkingOnSpecificDay(self): ''' prints a list of people not working on specific day ''' year_input = input("Year: ") year = LL_Employee().checkIfValidDate(year_input) if year == None: print("\n:: Not a valid year ::") else: month_input = input("Month: ") month = LL_Employee().checkIfValidDate(month_input) if month == None: print("\n:: Not a valid month ::") else: day_input = input("Day: ") day = LL_Employee().checkIfValidDate(day_input) if day == None: print("\n:: Not a valid day ::") else: print() start_time = datetime.datetime(year, month, day, 0, 0, 0).isoformat() result_employees = LL_Employee().EmployeesNotWorking(start_time) print('{:^44}'.format('Pilots')) print('.'*44) print() for crewMember in result_employees: if crewMember.rank == 'Captain': print(crewMember.name, '-',crewMember.rank) elif crewMember.rank == 'Copilot': print(crewMember.name, '-',crewMember.rank) print('\n{:^44}'.format('Cabin crew')) print('.'*44) print() for crewMember in result_employees: if crewMember.rank == 'Flight Service Manager': print(crewMember.name, '-',crewMember.rank) elif crewMember.rank == 'Flight Attendant': print(crewMember.name, '-',crewMember.rank)
def SetCabinCrew(self): ''' set new cabin crew ''' ssn = input('Social security number: ') valid_ssn = LL_Employee().checkIfValidssn(ssn) if valid_ssn == None: print(":: Not a valid social security number ::") else: name = input('Full name: ').title() firstname = name.split() role = 'Cabincrew' rank = input('Rank: ') pilot_license = 'N/A' address = input('Address: ') try: phone = int(input('Phone: ')) except ValueError: print("\n:: Invalid phone ::\n") phone = input('Phone: ') email = firstname[0] + "@nan.is" employee = Model_Employee(ssn, name, role, rank, pilot_license, address, phone, email) LL_Employee().createEmployee(employee) print("\n:: {} has been added to Cabin crew ::".format(name))
def listAllEmployeesWorkingOnSpecificDay(self): ''' prints a list of people working on specific day ''' year_input = input("Year: ") year = LL_Employee().checkIfValidDate(year_input) if year == None: print("Not a valid year") else: month_input = input("Month: ") month = LL_Employee().checkIfValidDate(month_input) if month == None: print("Not a valid month") else: day_input = input("Day: ") day = LL_Employee().checkIfValidDate(day_input) if day == None: print("Not a valid day") else: print() start_time = datetime.datetime(year, month, day, 0, 0, 0).isoformat() employee_dict = LL_Employee().EmployeesWorking(start_time) print('\n{:^44}'.format('Pilots')) print('.'*44) for crewMember, voyage in employee_dict.items(): if crewMember.role == 'Pilot': print('\n{} - {}\n'.format(crewMember.name, crewMember.rank)) print('\t {} - {}'.format(voyage.flightOut.departingFrom, voyage.flightOut.arrivingAt)) print('\t {} - {}'.format(voyage.flightBack.departingFrom, voyage.flightBack.arrivingAt)) print() print('\n{:^44}'.format('Cabin crew')) print('.'*44) for crewMember, voyage in employee_dict.items(): if crewMember.role == 'Cabincrew': print('\n{} - {}\n'.format(crewMember.name, crewMember.rank)) print('\t {} - {}'.format(voyage.flightOut.departingFrom, voyage.flightOut.arrivingAt)) print('\t {} - {}'.format(voyage.flightBack.departingFrom, voyage.flightBack.arrivingAt)) print()
def get_License(self, license): return LL_Employee().get_License(license)
def getOneEmployeeName(self, userName): return LL_Employee().getOneEmployeeName(userName)
def getOneEmployeeLicense(self, userLicense): return LL_Employee().getOneEmployeeLicense(userLicense)
def createEmployee(self, employeeToCreate): return LL_Employee().createEmployee(employeeToCreate)
def change_Employee(self, ChangeEmployee): return LL_Employee().change_Employee(ChangeEmployee)
def FaNotWorking(self, start_time): return LL_Employee().FaNotWorking(start_time)
def EmployeesWorking(self, start_time): return LL_Employee().EmployeesWorking(start_time)
def CaptainNotWorking(self, start_time): return LL_Employee().CaptainNotWorking(start_time)
def listPilots_planetype(self): return LL_Employee().listPilots_planetype()
def EmployeesVoyagesInSpecificWeek(self, ssn, result): return LL_Employee().EmployeesVoyagesInSpecificWeek(ssn, result)
def PilotWithLisence(self, pilot_list, aircraftID): return LL_Employee().PilotWithLisence(pilot_list, aircraftID)
def checkIfValidssn(self, ssn): return LL_Employee().checkIfValidssn(ssn)
def get_Cabin(self): return LL_Employee().get_Cabin()
def checkIfValidDate(self, user_input): return LL_Employee().checkIfValidDate(user_input)
def CopilotNotWorking(self, start_time, captain_on_voyage): return LL_Employee().CopilotNotWorking(start_time, captain_on_voyage)