コード例 #1
0
class InvoiceUI:

    def __init__(self):
        self.general = GeneralUI()
        self.logic = LogicAPI()
        self.invoice_menu()

    #Menu header

    def print_select_option(self):
        return input(">> Select option: ").lower()
    
    def print_table_header(self):
        print()
        print(f'{"Invoice ID":<20}{"Contract ID":<20}{"Customer SSN":<20}{"Vehicle ID":<20}{"Rate(€)":<20}{"Days total":<20}{"Total price(€)":<20}{"Late fee(€)":<20}{"State":<20}')
        print("="*180)

    #Print Contract Table Footer
    def print_table_footer(self):
        print("-"*180)
        print()

    def invoice_menu(self):
        while True:
            self.general.ui_menu_header("Invoice Menu")
            self.ui_numbered_menu(["Print invoice list", "Search for invoice by unique ID", "Send invoice", "Mark invoice as paid", "Main menu"])
            self.general.ui_menu_footer()
            choice = self.print_select_option()
            if choice == '1':
                self.print_table_header()
                for i in self.logic.get_all_invoices():
                    print(i)
                self.print_table_footer()
            elif choice == '2':
                id_invoice = input(">> Enter invoice ID: ")
                self.print_table_header()
                for i in self.logic.search_invoices(id_invoice):
                    print(i)
            elif choice == '3':
                invoice_ID = input(">> Enter contract ID: ")
                print(self.logic.create_invoice(invoice_ID))
            elif choice == '4':
                id_invoice = input(">> Enter invoice ID: ")
                print(self.logic.set_invoice_to_paid(id_invoice))
            elif choice == '5':
                return
            else:
                print('Invalid command, try again.')


    #Prints any UI menu in numbered list
    def ui_numbered_menu(self, a_list):
        '''Takes a list as parameter and prints all the items of a list in an order from 1. list[0], 2. list[1] and so on'''
        for i in range(0,(len(a_list))):
            print(f"{i+1}. {a_list[i]}")
コード例 #2
0
 def __init__(self):
     self.general = GeneralUI()
     self.logic = LogicAPI()
     self.report_main_menu()
コード例 #3
0
class ReportUI:
    def __init__(self):
        self.general = GeneralUI()
        self.logic = LogicAPI()
        self.report_main_menu()

    def ui_menu_header(self, menu_name):
        print("\n" + "-" * 20 + f"{menu_name}" + "-" * 20)

    def ui_menu_footer(self):
        print("\n" + "-" * 50)

    #Prints any UI menu in numbered list
    def ui_numbered_menu(self, a_list):
        '''Takes a list as parameter and prints all the items of a list in an order from 1. list[0], 2. list[1] and so on'''
        for i in range(0, (len(a_list))):
            print(f"{i+1}. {a_list[i]}")

    def print_select_option(self):
        return input(">> Select option: ").lower()

    def contract_table_header(self):
        print()
        print(
            f'{"Contract ID":<20}{"Customer Name":<20}{"Customer SSN":<20}{"Vehicle ID":<20}{"Contract Duration":<31}{"Country":<20}{"Employee":<20}{"Total price":<20}{"Creation Date":<20}{"Check-out Date":<20}{"Check-in Date":<20}{"Check-in Location":<20}{"State":<20}'
        )
        print("=" * 260)

    def print_table_footer(self):
        print("-" * 60)
        print()

    def revenue_table_header(self):
        print()
        print(f'{"Date":<20}{"Location":<20}{"Revenue(€)":<20}')
        print("=" * 60)

    #Print Vehicle Table Header
    def utility_table_header(self):
        print(
            f"{'Location':<40}{'Vehicle Type':<40}{'Days rented in a year (%)':<50}"
        )
        print("-" * 100)

    def utility_table_footer(self):
        print("-" * 100)

    ### CONTRACT MAIN MENU ###
    def report_main_menu(self):
        while True:
            self.ui_menu_header("Reports")
            print("\nPlease select a an option:")
            self.ui_numbered_menu(
                ["Revenues", "Vehicle Usability", "Main Menu"])
            self.ui_menu_footer()
            command = self.print_select_option()
            if command == "1":
                start_date = input(">> Input start date in format dd.mm.yy: ")
                end_date = input(">> Input end date in format dd.mm.yy: ")
                self.revenue_statistics(start_date, end_date)
            elif command == "2":  # 2. Vehicle usability
                result_dict = self.logic.result_list()
                self.utility_table_header()
                for key, val in result_dict.items():
                    print(f"{key}")
                    for k, v in val.items():
                        print(f"{'':<40}{k:<40}{v:<50.2f}")
                    print("-" * 100)
                self.utility_table_footer()
            elif command == "3":
                return
            else:
                print("Invalid command, try again")

    def revenue_statistics(self, start_date, end_date):
        search_list = self.logic.revenue_by_date(start_date, end_date)
        if search_list == 'No revenue to show during that time period.':
            print(f'\n***** {search_list} *****')
            return
        else:
            self.revenue_table_header()
            for result in search_list:
                print(
                    f'{result.checkout_date:<20}{result.country:<20}{result.total_price:<20}'
                )
            self.print_table_footer()
コード例 #4
0
 def __init__(self):
     self.general = GeneralUI()
     self.logic = LogicAPI()
     self.contract_main_menu()
コード例 #5
0
class ContractUI:
    def __init__(self):
        self.general = GeneralUI()
        self.logic = LogicAPI()
        self.contract_main_menu()

    ### GENERAL FUNCTIONS ###

    #Prints any UI menu in numbered list
    def ui_numbered_menu(self, a_list):
        '''Takes a list as parameter and prints all the items of a list in an order from 1. list[0], 2. list[1] and so on'''
        for i in range(0, (len(a_list))):
            print(f"{i+1}. {a_list[i]}")

    def print_select_option(self):
        return input(">> Select option: ").lower()

    def print_table_header(self):
        print()
        print(
            f'{"Contract ID":<15}{"Customer Name":<15}{"Customer SSN":<15}{"Vehicle ID":<15}{"Contract Duration":<25}{"Country":<15}{"Employee":<15}{"Total price":<15}{"Creation Date":<15}{"Check-out Date":<15}{"Check-in Date":<15}{"Check-in Location":<25}{"State":<15}'
        )
        print("=" * 260)

    #Print Contract Table Footer
    def print_table_footer(self):
        print("-" * 260)
        print()

    def validate(self, date_text):
        try:
            datetime.datetime.strptime(date_text, '%d.%m.%y')
            return True
        except ValueError:
            print("\nIncorrect input, make sure the format is DD.MM.YY\n")
            return False

    def ui_country_available_print(self):
        '''Prints all destination type categories'''
        print("\nAvailable Options:")
        destinations = self.logic.available_country()
        for destination in destinations:
            print("\t" + destination)
        print()
        return destinations

    #Prints UI for new contract
    def new_contract(self):
        contractFieldnames = [
            "Customer name", "Customer Social Security No.", "Vehicle ID",
            "Start date of rental period (dd.mm.yy)",
            "End date of rental period (dd.mm.yy)", "Country", "Employee name",
            "Total price"
        ]  # + "Contract Creation Date"
        inputList = []
        print("\nPress 'q' and hit 'enter' to cancel at any time.")
        print("\nPlease enter the following details to create a new contract:")
        user_input = ""
        for field in contractFieldnames:
            if field == "Country":
                destinations = self.ui_country_available_print()
                user_input = ""
                while user_input not in destinations:
                    user_input = input(f"Enter {field}: ")
                    if user_input == "q":
                        break
            else:
                user_input = input(f"Enter {field}: ")
                if user_input.lower() == "q":
                    return self.contract_main_menu()
                #Checks start date format
                if contractFieldnames.index(field) == 3:
                    date_check = False
                    while user_input != "q":
                        date_check = self.validate(user_input)
                        if date_check == False:
                            user_input = input(f"Enter {field}: ")
                        else:
                            start_date = datetime.datetime.strptime(
                                user_input, '%d.%m.%y')
                            yesterday = datetime.datetime.today(
                            ) - datetime.timedelta(days=1)
                            if start_date <= yesterday:
                                print("Dates before today are invalid")
                                user_input = input(f"Enter {field}: ")
                            else:
                                break
                #Checks end date format
                elif contractFieldnames.index(field) == 4:
                    date_check = False
                    while user_input != "q":
                        date_check = self.validate(user_input)
                        if date_check == False:
                            user_input = input(f"Enter {field}: ")
                        else:
                            end_date = datetime.datetime.strptime(
                                user_input, '%d.%m.%y')
                            if start_date > end_date:
                                print("Dates before start date are invalid.")
                                user_input = input(f"Enter {field}: ")
                            else:
                                break
            inputList.append(user_input)
        #Add Contract creation date "Contract Creation Date"
        contract_creation_date = datetime.datetime.today()
        contract_creation_date = contract_creation_date.strftime('%d.%m.%y')
        inputList.append(contract_creation_date)
        return inputList

    ### CONTRACT MAIN MENU ###
    def contract_main_menu(self):
        while True:
            self.general.ui_menu_header("Contract Menu")
            print("\nPlease select a an option:")
            self.ui_numbered_menu([
                "Create contract", "Search contracts", "View all contracts",
                "Edit contract", "Cancel contract", "Delete contract",
                "Main menu"
            ])
            self.general.ui_menu_footer()
            command = self.print_select_option()
            if command == "1":  #1. Create contract
                contract_param = self.new_contract()
                print(self.logic.create_new_contract(contract_param))
            elif command == "2":  # 2. Search contracts
                self.contract_search_menu()
            elif command == "3":  # 3. View all contracts
                self.print_table_header()
                for item in self.logic.all_contracts():
                    print(item)
                self.print_table_footer()
            elif command == "4":  # 4. Edit contracts
                self.ui_all_contracts()
                edited_contract = self.ui_edit_contract()
                self.print_table_header()
                print(edited_contract)
                self.print_table_footer()
            elif command == "5":  # 5. Cancel contract
                self.ui_all_contracts()
                self.canceled_contract()
            elif command == "6":  # 6. Delete contract
                contract_id = input(">> Enter contract ID to delete: ")
                result_list = self.logic.delete_contract(contract_id)
                for item in result_list:
                    print(item, end="")
            elif command == "7":
                return
            else:
                print("Invalid command, try again")

    ### CONTRACT SEARCH MENU ###

    def contract_search_menu(self):
        while True:
            self.general.ui_menu_header("Contract Search")
            print("\nPlease select search option:")
            self.ui_numbered_menu([
                "Search by Contract ID", "Search by Customer name",
                "Search by Vehicle ID", "Main menu"
            ])
            self.general.ui_menu_footer()
            command = self.print_select_option()
            if command == "1":
                contract_id = input(">> Enter Contract ID: ")
                a_list = self.logic.search_contracts_by_id(contract_id)
                self.print_table_header()
                for item in a_list:
                    print(item)
            elif command == "2":
                vehicle_id = input(">> Enter Customer name: ")
                a_list = self.logic.search_contracts_by_customer(vehicle_id)
                self.print_table_header()
                for item in a_list:
                    print(item)
            elif command == "3":
                vehicle_id = input(">> Enter vehicle ID: ")
                a_list = self.logic.search_contract_by_vin(vehicle_id)
                self.print_table_header()
                for item in a_list:
                    print(item)
            elif command == "4":
                return
            else:
                print("Invalid command, try again")

    def canceled_contract(self):
        contract_ID = input(">> Enter contract ID: ")
        while True:
            command = input(
                "Are you sure you want to cancel contract? (Y)es or (N)o? ")
            command = command.lower()
            if command == "y":
                contracts = self.logic.search_contracts_by_id(contract_ID)
                for contract in contracts:
                    contract.state = "CANCELED"
                    return self.logic.edit_contract(contract)
            elif command == "n":
                return
            else:
                print("\n*** Please select either (Y)es or (N)o ***\n")

    #Creates the Edit menu layout and returns the Contract Instance after edit
    def ui_edit_contract(self):
        contracts = self.ui_single_contract_ID(
        )  #returns a list of contracts, in this case only one contract
        selection = ""
        while selection != "8":
            self.ui_print_edit_menu()  #ask user what he would like to edit
            selection = self.general.ui_edit_input()
            if selection == "1":
                for contract in contracts:
                    contract.customer = self.value_input()
            elif selection == "2":
                for contract in contracts:
                    contract.vehicle_unique_id = self.value_input()
            elif selection == "3":
                for contract in contracts:
                    contract.start_date = self.value_input()
            elif selection == "4":
                for contract in contracts:
                    contract.end_date = self.value_input()
            elif selection == "5":
                for contract in contracts:
                    contract.country = self.value_input()
            elif selection == "6":
                for contract in contracts:
                    contract.employee = self.value_input()
            elif selection == "7":
                for contract in contracts:
                    contract.total_price = self.value_input()
            elif selection == "8":
                return contract

    #Prints the Vehicle Edit menu options
    def ui_print_edit_menu(self):
        '''Prints options for Edit menu and accepts input'''
        self.general.ui_menu_header("Edit vehicle")
        print("\nSelect field to edit:")
        print("1. Customer name")
        print("2. Vehicle ID")
        print("3. Start date")
        print("4. End date")
        print("5. Country")
        print("6. Employee name")
        print("7. Total price")
        print("8. Exit")
        self.general.ui_menu_footer()

    #Prints contract with unique ID
    def ui_single_contract_ID(self):
        '''Prints a single vehicle with a unique ID'''
        contract_ID = input(">> Enter contract ID: ")
        contract = self.logic.search_contracts_by_id(contract_ID)
        print("\Contract by ID: " + contract_ID)
        self.print_table_header()
        for single_contract in contract:
            print(single_contract)
        self.print_table_footer()
        return contract

    #Request new value from user
    def value_input(self):
        return input("Enter new value: ")

    #Prints all contracts
    def ui_all_contracts(self):
        contracts = self.logic.all_contracts()
        print("\nAll Contracts:")
        self.print_table_header()
        for contract in contracts:
            print(contract)
        self.print_table_footer()
コード例 #6
0
ファイル: DestinationUI.py プロジェクト: raggiok/VLN1
 def __init__(self):
     self.general = GeneralUI()
     self.logicAPI = LogicAPI()
     self.destination_menu()
コード例 #7
0
ファイル: DestinationUI.py プロジェクト: raggiok/VLN1
class destinationUI:
    def __init__(self):
        self.general = GeneralUI()
        self.logicAPI = LogicAPI()
        self.destination_menu()
        # self.ui_print_type()

    #Prints UI for new destination
    def ui_new_destination(self):
        destinationFieldnames = [
            "country", "city", "airport", "phone_number", "opening_time",
            "closing_time", "main_contact"
        ]
        inputList = []
        print("\nPress 'q' and hit 'enter' to cancel at any time.")
        print(
            "\nPlease enter the following details to create a new destination:"
        )
        user_input = ""
        user_input = ""
        for field in destinationFieldnames:
            if user_input.lower() == "q":
                return self.destination_menu()
            user_input = input(f"Enter {field}: ")
            inputList.append(user_input)
        return inputList

    #Request new value from user
    def value_input(self):
        return input("Enter new value: ")

    #Creates the Edit menu layout and returns the destination Instance after edit
    def ui_edit_destination(self):
        self.ui_all_destinations()
        destination = self.ui_single_destination_ID(
        )  #prints specific destination
        selection = ""

        while selection != "9":
            self.ui_print_edit_menu()  #ask user what he would like to edit
            selection = self.general.ui_edit_input()
            if selection == "1":
                destination.country = self.value_input()
            elif selection == "2":
                destination.city = self.value_input()
            elif selection == "3":
                destination.airport = self.value_input()
            elif selection == "4":
                destination.phone_number = self.value_input()
            elif selection == "5":
                destination.opening_time = self.value_input()
            elif selection == "6":
                destination.closing_time = self.value_input()
            elif selection == "7":
                destination.main_contact = self.value_input()
            elif selection == "8":
                destination.state = self.value_input()
            elif selection == "9":
                return destination

    #Prints the destination Edit menu options
    def ui_print_edit_menu(self):
        '''Prints options for Edit menu and accepts input'''
        self.general.ui_menu_header("Edit destination")
        print("\nSelect field to edit:")
        print("1. Country")
        print("2. City")
        print("3. Airport")
        print("4. Phone Number")
        print("5. Opening Time")
        print("6. Closing Time")
        print("7. Main Contact")
        print("8. State")
        print("9. Exit")
        self.general.ui_menu_footer()

    #Print Destination Table Header
    def ui_destination_table_header(self):
        print(
            f"{'Unique ID':<20}{'Country':<20}{'City':<20}{'Airport':<20}{'Phone Number':<20}{'Opening Time':<20}{'Closing Time':<20}{'Main Contact':<20}"
        )
        print("-" * 200)

    #Print destination Table Footer
    def ui_destination_table_footer(self):
        print("-" * 200)
        print()

    #Prints all destinations
    def ui_all_destinations(self):
        results = self.logicAPI.all_destinations()
        print("\nAll destinations:")
        self.ui_destination_table_header()
        for destination in results:
            print(destination)
        self.ui_destination_table_footer()

    #Prints destination with unique ID
    def ui_single_destination_ID(self):
        '''Prints a single destination with a unique ID'''
        destination_ID = input(">> Please enter destination ID: ")
        destination = self.logicAPI.search_destinations_by_id(destination_ID)
        print("\ndestination by ID: " + destination_ID)
        self.ui_destination_table_header()
        for destination in destination:
            print(destination)
        self.ui_destination_table_footer()
        return destination

    ### search function ###

    def ui_country_available_print(self):
        '''Prints all destination type categories'''
        print("\nAvailable Options:")
        destinations = self.logicAPI.available_country()
        for destination in destinations:
            print("\t" + destination)
        print()

    def ui_city_available_print(self):
        '''Prints all destination type categories'''
        print("\nAvailable Options:")
        destinations = self.logicAPI.available_city()
        for destination in destinations:
            print("\t" + destination)
        print()

    def ui_airport_available_print(self):
        '''Prints all destination type categories'''
        print("\nAvailable Options:")
        destinations = self.logicAPI.available_airport()
        for destination in destinations:
            print("\t" + destination)
        print()

    def ui_phone_number_available_print(self):
        '''Prints all destination type categories'''
        print("\nAvailable Options:")
        destinations = self.logicAPI.available_phone_number()
        for destination in destinations:
            print("\t" + destination)
        print()

    def ui_opening_time_available_print(self):
        '''Prints all destination type categories'''
        print("\nAvailable Options:")
        destinations = self.logicAPI.available_opening_time()
        for destination in destinations:
            print("\t" + destination)
        print()

    def ui_closing_time_available_print(self):
        '''Prints all destination type categories'''
        print("\nAvailable Options:")
        destinations = self.logicAPI.available_closing_time()
        for destination in destinations:
            print("\t" + destination)
        print()

    def ui_main_contact_available_print(self):
        '''Prints all destination type categories'''
        print("\nAvailable Options:")
        destinations = self.logicAPI.available_main_contact()
        for destination in destinations:
            print("\t" + destination)
        print()

    def ui_print_country(self):
        self.ui_country_available_print()
        country = input(">> Please enter destination Country: ")
        results = self.logicAPI.search_destination_by_country(country)
        print("\nSearch results for " + country + ": ")
        self.ui_destination_table_header()
        for destination in results:
            print(destination)
        self.ui_destination_table_footer()

    def ui_print_city(self):
        self.ui_city_available_print()
        city = input(">> Please enter destination City: ")
        results = self.logicAPI.search_destination_by_city(city)
        print("\nSearch results for " + city + ": ")
        self.ui_destination_table_header()
        for destination in results:
            print(destination)
        self.ui_destination_table_footer()

    def ui_print_airport(self):
        self.ui_airport_available_print()
        airport = input(">> Please enter destination Airport: ")
        results = self.logicAPI.search_destination_by_city(airport)
        print("\nSearch results for " + airport + ": ")
        self.ui_destination_table_header()
        for destination in results:
            print(destination)
        self.ui_destination_table_footer()

    def ui_print_phone_number(self):
        self.ui_phone_number_available_print()
        phone_number = input(">> Please enter destination Phone number: ")
        results = self.logicAPI.search_destination_by_phone_number(
            phone_number)
        print("\nSearch results for " + phone_number + ": ")
        self.ui_destination_table_header()
        for destination in results:
            print(destination)
        self.ui_destination_table_footer()

    def ui_print_opening_time(self):
        self.ui_opening_time_available_print()
        opening_time = input(">> Please enter destination Opening time: ")
        results = self.logicAPI.search_destination_by_opening_time(
            opening_time)
        print("\nSearch results for " + opening_time + ": ")
        self.ui_destination_table_header()
        for destination in results:
            print(destination)
        self.ui_destination_table_footer()

    def ui_print_closing_time(self):
        self.ui_closing_time_available_print()
        closing_time = input(">> Please enter destination Closing time: ")
        results = self.logicAPI.search_destination_by_closing_time(
            closing_time)
        print("\nSearch results for " + closing_time + ": ")
        self.ui_destination_table_header()
        for destination in results:
            print(destination)
        self.ui_destination_table_footer()

    def ui_print_main_contact(self):
        self.ui_main_contact_available_print()
        main_contact = input(">> Please enter destination Main contact: ")
        results = self.logicAPI.search_destination_by_main_contact(
            main_contact)
        print("\nSearch results for " + main_contact + ": ")
        self.ui_destination_table_header()
        for destination in results:
            print(destination)
        self.ui_destination_table_footer()

    ### search function ###

    #Prints the search menu for destinations
    def ui_search_menu(self):
        self.general.ui_menu_header("Destination Search")
        print("\nPlease select a search option:")
        self.UI_numbered_menu([
            "Country", "City", "Airport", "Phone Number", "Opening Time",
            "Closing Time", "Main Contact", "Exit"
        ])
        self.general.ui_menu_footer()
        selection = input("\n>> Select option: ")
        return selection

    #Prints any UI menu in order
    def UI_numbered_menu(self, a_list):
        '''Takes a list as parameter and prints all the items of a list in an order from 1. list[0], 2. list[1] and so on'''
        for i in range(0, (len(a_list))):
            print(f"{i+1}. {a_list[i]}")

    #Prints the destination Main Menu
    def destination_menu(self):
        while True:
            self.general.ui_menu_header("Destination Menu")
            print(
                "\nSelect an option...\n1. Create new destination \n2. Search destinations \n3. View all destinations \n4. Edit destination \n5. Delete destination \n6. Main Menu"
            )
            self.general.ui_menu_footer()
            command = input(">> Select option: ")
            command = command.lower()
            if command == "1":
                new_destination = self.ui_new_destination()
                self.logicAPI.create_destination(*new_destination)
            elif command == "2":
                selection = self.ui_search_menu()
                if selection == "1":
                    self.ui_print_country()
                elif selection == "2":
                    self.ui_print_city()
                elif selection == "3":
                    self.ui_print_airport()
                elif selection == "4":
                    self.ui_print_phone_number()
                elif selection == "5":
                    self.ui_print_opening_time()
                elif selection == "6":
                    self.ui_print_closing_time()
                elif selection == "7":
                    self.ui_print_main_contact()
                elif selection == "8":
                    return
            elif command == "3":
                self.ui_all_destinations()
            elif command == "4":
                new_destination = self.ui_edit_destination()
                self.logicAPI.edit_destination(new_destination)
            elif command == "5":
                self.ui_all_destinations()
                destination_id = input(">> Enter destination ID to delete: ")
                destination = self.logicAPI.delete_destination(destination_id)
                for result in destination:
                    print(result)
            elif command == "6":
                return
            else:
                print("Invalid command, try again")
コード例 #8
0
 def __init__(self):
     self.general = GeneralUI()
     self.logic = LogicAPI()
     self.invoice_menu()
コード例 #9
0
ファイル: CustomerUI.py プロジェクト: raggiok/VLN1
class CustomerUI:
    def __init__(self):
        self.general = GeneralUI()
        self.logicAPI = LogicAPI()
        self.customer_menu()

    #unique_id,name,ssn,address,zip_code,city,country,phone,email,state
    #create new customer
    def ui_new_customer(self):
        customerFieldnames = [
            "name", "ssn", "address", "zip_code", "city", "country", "phone",
            "email"
        ]
        inputList = []
        print("\nPress 'q' and hit 'enter' to cancel at any time.")
        print("\nPlease enter the following details to create a new customer:")
        user_input = ""
        for field in customerFieldnames:
            if user_input.lower() == "q":
                return
            user_input = input(f"Enter {field}: ")
            inputList.append(user_input)
        return inputList

    #choose the number to edit
    def value_input(self):
        return input("Enter new value: ")

    #unique_id,name,ssn,address,zip_code,city,country,phone,email,state
    #Creates the Edit menu layout and returns the customer Instance after edit
    def ui_edit_customer(self):
        customer = self.ui_single_customer_unique()  #prints specific customer
        selection = ""
        while selection != "9":
            self.ui_print_edit_menu()
            selection = self.general.ui_edit_input()
            if selection == "1":
                customer.name = self.value_input()
            elif selection == "2":
                customer.ssn = self.value_input()
            elif selection == "3":
                customer.address = self.value_input()
            elif selection == "4":
                customer.zip_code = self.value_input()
            elif selection == "5":
                customer.city = self.value_input()
            elif selection == "6":
                customer.country = self.value_input()
            elif selection == "7":
                customer.phone = self.value_input()
            elif selection == "8":
                customer.email = self.value_input()
            elif selection == "9":
                return customer

    #unique_id,name,ssn,address,zip_code,city,country,phone,email,state
    #Prints the Customer Edit menu options
    def ui_print_edit_menu(self):
        '''Prints options for Edit menu and accepts input'''
        self.general.ui_menu_header("Edit customer")
        print("\nSelect field to edit:")
        print("1. Name")
        print("2. Social Security No.")
        print("3. Address")
        print("4. Zip code")
        print("5. City")
        print("6. Country")
        print("7. Phone")
        print("8. Email")
        print("9. Exit")
        self.general.ui_menu_footer()

    #name,ssn,address,zip_code,city,country,phone,email,state
    #Print Customer Table Header
    def ui_customer_table_header(self):
        print(
            f"{'Customer ID':<20}{'Name':<20}{'SSN':<20}{'Address':<20}{'Zip code':<20}{'City':<20}{'Country':<20}{'Phone':<20}{'Email':<20}"
        )
        print("-" * 200)

    #Print Customer Table Footer
    def ui_customer_table_footer(self):
        print("-" * 200)
        print()

    #Print all customer
    def ui_all_customer(self):
        results = self.logicAPI.all_customer()
        print("\nAll customers:")
        self.ui_customer_table_header()
        for customer in results:
            print(customer)
        self.ui_customer_table_footer()

    #Prints customer with unique ID
    def ui_single_customer_unique(self):
        '''Prints a single customer with a unique ID'''
        customer_unique = input(">> Please enter customer ID: ")
        customers = self.logicAPI.search_customer_by_unique(customer_unique)
        print("\ncustomer by ID: " + customer_unique)
        self.ui_customer_table_header()
        for customer in customers:
            print(customer)
        self.ui_customer_table_footer()
        return customer

    #name,ssn,address,zip_code,city,country
    ###availability option search ###
    def ui_name_available_print(self):
        '''Prints all customer name'''
        print("\nAvailable Options:")
        customers = self.logicAPI.available_customer_name()
        for customer in customers:
            print("\t" + customer)
        print()

    def ui_ssn_available_print(self):
        '''Prints all customer SSN'''
        print("\nAvailable Options:")
        customers = self.logicAPI.available_customer_ssn()
        for customer in customers:
            print("\t" + customer)
        print()

    def ui_address_available_print(self):
        '''Prints all customer address'''
        print("\nAvailable Options:")
        customers = self.logicAPI.available_customer_address()
        for customer in customers:
            print("\t" + customer)
        print()

    def ui_zip_code_available_print(self):
        '''Prints all customer zip_code'''
        print("\nAvailable Options:")
        customers = self.logicAPI.available_customer_zip_code()
        for customer in customers:
            print("\t" + customer)
        print()

    def ui_city_available_print(self):
        '''Prints all customer city'''
        print("\nAvailable Options:")
        customers = self.logicAPI.available_customer_city()
        for customer in customers:
            print("\t" + customer)
        print()

    def ui_country_available_print(self):
        '''Prints all customer country'''
        print("\nAvailable Options:")
        customers = self.logicAPI.available_customer_country()
        for customer in customers:
            print("\t" + customer)
        print()

    #name,ssn,address,zip_code,city,country
    #Print the availability data
    def ui_print_country(self):
        self.ui_country_available_print()
        country = input(">> Please enter customer Country: ")
        results = self.logicAPI.search_customers_by_country(country)
        print("\nSearch results for " + country + ": ")
        self.ui_customer_table_header()
        for customer in results:
            print(customer)
        self.ui_customer_table_footer()

    def ui_print_city(self):
        self.ui_city_available_print()
        city = input(">> Please enter customer City: ")
        results = self.logicAPI.search_customers_by_city(city)
        print("\nSearch results for " + city + ": ")
        self.ui_customer_table_header()
        for customer in results:
            print(customer)
        self.ui_customer_table_footer()

    def ui_print_zip_code(self):
        self.ui_zip_code_available_print()
        zip_code = input(">> Please enter customer zip_code: ")
        results = self.logicAPI.search_customers_by_zip_code(zip_code)
        print("\nSearch results for " + zip_code + ": ")
        self.ui_customer_table_header()
        for customer in results:
            print(customer)
        self.ui_customer_table_footer()

    def ui_print_address(self):
        self.ui_address_available_print()
        address = input(">> Please enter customer address: ")
        results = self.logicAPI.search_customers_by_address(address)
        print("\nSearch results for " + address + ": ")
        self.ui_customer_table_header()
        for customer in results:
            print(customer)
        self.ui_customer_table_footer()

    def ui_print_ssn(self):
        self.ui_ssn_available_print()
        ssn = input(">> Please enter customer ssn: ")
        results = self.logicAPI.search_customers_by_id(ssn)
        print("\nSearch results for " + ssn + ": ")
        self.ui_customer_table_header()
        for customer in results:
            print(customer)
        self.ui_customer_table_footer()

    def ui_print_name(self):
        self.ui_name_available_print()
        name = input(">> Please enter customer name: ")
        results = self.logicAPI.search_customers_by_name(name)
        print("\nSearch results for " + name + ": ")
        self.ui_customer_table_header()
        for customer in results:
            print(customer)
        self.ui_customer_table_footer()

    #Print search menu
    def ui_search_menu(self):
        self.general.ui_menu_header("Customer Search")
        print("\nPlease enter search option:")
        self.UI_numbered_menu([
            "Name", "Social Security No.", "Address", "Zip Code", "City",
            "Country", "Exit"
        ])
        self.general.ui_menu_footer()
        selection = input("\n>> Select option: ").lower()
        return selection

    #Prints any UI menu in order
    def UI_numbered_menu(self, a_list):
        '''Takes a list as parameter and prints all the items of a list in an order from 1. list[0], 2. list[1] and so on'''
        for i in range(0, (len(a_list))):
            print(f"{i+1}. {a_list[i]}")

    #name	ssn	address	zip_code	city	country
    #Print customer main menu
    def customer_menu(self):
        while True:
            self.general.ui_menu_header("Customer Menu")
            print(
                "\nSelect an option...\n1. Create new customer \n2. Search customer \n3. View all customers \n4. Edit customer \n5. Delete customer \n6. Main menu "
            )
            self.general.ui_menu_footer()
            command = input(">> Select option: ").lower()
            command = command.lower()
            if command == "1":
                new_customer = self.ui_new_customer()
                self.logicAPI.create_customer(new_customer)
            elif command == "2":
                selection = self.ui_search_menu()
                if selection == "1":
                    self.ui_print_name()
                elif selection == "2":
                    self.ui_print_ssn()
                elif selection == "3":
                    self.ui_print_address()
                elif selection == "4":
                    self.ui_print_zip_code()
                elif selection == "5":
                    self.ui_print_city()
                elif selection == "6":
                    self.ui_print_country()
                elif selection == "7":
                    self.customer_menu()
            elif command == "3":
                self.ui_all_customer()
            elif command == "4":
                new_customer = self.ui_edit_customer()
                self.logicAPI.update_customer(new_customer)
            elif command == "5":
                customer_id = input(">> Enter customer ID to delete: ")
                customer = self.logicAPI.delete_customer(customer_id)
                for result in customer:
                    print(result)
            elif command == "6":
                return
            else:
                print("Invalid command, try again")
コード例 #10
0
 def __init__(self):
     self.general = GeneralUI()
     self.logic = LogicAPI()
     self.vehicle_menu()
コード例 #11
0
class VehicleUI:
    def __init__(self):
        self.general = GeneralUI()
        self.logic = LogicAPI()
        self.vehicle_menu()
        # self.ui_print_type()

    #Prints UI for new vehicle
    def ui_new_vehicle(self):
        vehicleFieldnames = [
            "Manufacturer", "Model", "Vehicle type", "Status",
            "Manufacturing year", "Color", "License Requirement", "Location",
            "Rate"
        ]
        inputList = []
        print("\nPress 'q' and hit 'enter' to cancel at any time.")
        print("\nPlease enter the following details to create a new vehicle:")
        user_input = ""
        for field in vehicleFieldnames:
            if user_input.lower() == "q":
                return self.vehicle_menu()
            if field == "Location":
                user_input = ""
                destinations = self.ui_country_available_print()
                while user_input not in destinations:
                    user_input = input(f"Enter {field}: ")
            else:
                user_input = input(f"Enter {field}: ")
            inputList.append(user_input)
        return inputList

    #Request new value from user
    def value_input(self):
        return input("Enter new value: ")

    #Creates the Edit menu layout and returns the Vehicle Instance after edit
    def ui_edit_vehicle(self):
        vehicle = self.ui_single_vehicle_ID()  #prints specific vehicle
        selection = ""
        while selection != "9":
            self.ui_print_edit_menu()  #ask user what he would like to edit
            selection = self.general.ui_edit_input()
            if selection == "1":
                vehicle.manufacturer = self.value_input()
            elif selection == "2":
                vehicle.model = self.value_input()
            elif selection == "3":
                vehicle.vehicle_type = self.value_input()
            elif selection == "4":
                vehicle.status = self.value_input()
            elif selection == "5":
                vehicle.man_year = self.value_input()
            elif selection == "6":
                vehicle.color = self.value_input()
            elif selection == "7":
                vehicle.license_type = self.value_input()
            elif selection == "8":
                vehicle.location = self.value_input()
            elif selection == "9":
                vehicle.rate = self.value_input()
            elif selection == "q":
                return vehicle

    #Prints the Vehicle Edit menu options
    def ui_print_edit_menu(self):
        '''Prints options for Edit menu and accepts input'''
        self.general.ui_menu_header("Edit vehicle")
        print("\nSelect field to edit:")
        print("1. Manufacturer")
        print("2. Model")
        print("3. Vehicle type")
        print("4. Status")
        print("5. Manufacturing year")
        print("6. Color")
        print("7. License Requirement")
        print("8. Location")
        print("9. Rate")
        print("q. Exit")
        self.general.ui_menu_footer()

    #Print Vehicle Table Header
    def ui_vehicle_table_header(self):
        print(
            f"{'Unique ID':<20}{'Manufacturer':<20}{'Model':<20}{'Vehicle type':<20}{'Status':<20}{'Manufac. year':<20}{'Color':<20}{'License Req.':<20}{'Location':<20}{'Rate':<20}"
        )
        print("-" * 200)

    #Print Vehicle Table Footer
    def ui_vehicle_table_footer(self):
        print("-" * 200)
        print()

    #Prints all vehicles
    def ui_all_vehicles(self):
        results = self.logic.all_vehicles()
        print("\nAll vehicles:")
        self.ui_vehicle_table_header()
        for vehicle in results:
            print(vehicle)
        self.ui_vehicle_table_footer()

    #Prints vehicle with unique ID
    def ui_single_vehicle_ID(self):
        '''Prints a single vehicle with a unique ID'''
        vehicle_ID = input(">> Please enter vehicle ID: ")
        vehicles = self.logic.search_vehicle_by_ID(vehicle_ID)
        print("\nVehicle by ID: " + vehicle_ID)
        self.ui_vehicle_table_header()
        for vehicle in vehicles:
            print(vehicle)
        self.ui_vehicle_table_footer()
        return vehicle

####################################################Search Menus##########################################################################

    def ui_manufacturer_available_print(self):
        print("\nAvailable Options:")
        vehicles = self.logic.available_manufacturers()
        for vehicle in vehicles:
            print("\t" + vehicle)
        print()

    def ui_model_available_print(self):
        print("\nAvailable Options:")
        vehicles = self.logic.available_model()
        for vehicle in vehicles:
            print("\t" + vehicle)
        print()

    def ui_vehicle_type_available_print(self):
        print("\nAvailable Options:")
        vehicles = self.logic.available_vehicle_type()
        for vehicle in vehicles:
            print("\t" + vehicle)
        print()

    def ui_status_available_print(self):
        print("\nAvailable Options:")
        vehicles = self.logic.available_status()
        for vehicle in vehicles:
            print("\t" + vehicle)
        print()

    def ui_manufacturing_year_available_print(self):
        print("\nAvailable Options:")
        vehicles = self.logic.available_manufacturing_year()
        for vehicle in vehicles:
            print("\t" + vehicle)
        print()

    def ui_color_available_print(self):
        print("\nAvailable Options:")
        vehicles = self.logic.available_color()
        for vehicle in vehicles:
            print("\t" + vehicle)
        print()

    def ui_license_type_available_print(self):
        print("\nAvailable Options:")
        vehicles = self.logic.available_license_type()
        for vehicle in vehicles:
            print("\t" + vehicle)
        print()

    def ui_location_available_print(self):
        print("\nAvailable Options:")
        vehicles = self.logic.available_location()
        for vehicle in vehicles:
            print("\t" + vehicle)
        print()

    def ui_print_manufacturer(self):
        self.ui_manufacturer_available_print()
        manufacturer = input(">> Please enter vehicle manufacturer: ")
        results = self.logic.search_vehicle_by_manufacturer(manufacturer)
        print("\nAll vehicles by manufacturer " + manufacturer + ": ")
        self.ui_vehicle_table_header()
        for vehicle in results:
            print(vehicle)
        self.ui_vehicle_table_footer()

    def ui_print_model(self):
        self.ui_model_available_print()
        model = input(">> Please enter vehicle model: ")
        results = self.logic.search_vehicle_by_model(model)
        print("\nAll vehicles by model " + model + ": ")
        self.ui_vehicle_table_header()
        for vehicle in results:
            print(vehicle)
        self.ui_vehicle_table_footer()

    def ui_print_vehicle_type(self):
        self.ui_vehicle_type_available_print()
        vehicle_type = input(">> Please enter vehicle type: ")
        results = self.logic.search_vehicle_by_vehicle_type(vehicle_type)
        print("\nAll vehicles by type " + vehicle_type + ": ")
        self.ui_vehicle_table_header()
        for vehicle in results:
            print(vehicle)
        self.ui_vehicle_table_footer()

    def ui_print_status(self):
        self.ui_status_available_print()
        status = input(">> Please enter vehicle status: ")
        results = self.logic.search_vehicle_by_status(status)
        print("\nAll vehicles by type " + status + ": ")
        self.ui_vehicle_table_header()
        for vehicle in results:
            print(vehicle)
        self.ui_vehicle_table_footer()

    def ui_print_manufacturing_year(self):
        self.ui_manufacturing_year_available_print()
        manufacturing_year = input(
            ">> Please enter vehicle manufacturing year: ")
        results = self.logic.search_vehicle_by_manufacturing_year(
            manufacturing_year)
        print("\nAll vehicles by manufacturing year " + manufacturing_year +
              ": ")
        self.ui_vehicle_table_header()
        for vehicle in results:
            print(vehicle)
        self.ui_vehicle_table_footer()

    def ui_print_color(self):
        self.ui_color_available_print()
        color = input(">> Please enter vehicle color: ")
        results = self.logic.search_vehicle_by_color(color)
        print("\nAll vehicles by color " + color + ": ")
        self.ui_vehicle_table_header()
        for vehicle in results:
            print(vehicle)
        self.ui_vehicle_table_footer()

    def ui_print_license_type(self):
        self.ui_license_type_available_print()
        license_type = input(">> Please enter vehicle license requirement: ")
        results = self.logic.search_vehicle_by_license_type(license_type)
        print("\nAll vehicles by type " + license_type + ": ")
        self.ui_vehicle_table_header()
        for vehicle in results:
            print(vehicle)
        self.ui_vehicle_table_footer()

    def ui_print_location(self):
        self.ui_location_available_print()
        location = input(">> Please enter vehicle location: ")
        results = self.logic.search_vehicle_by_location(location)
        print("\nAll vehicles by type " + location + ": ")
        self.ui_vehicle_table_header()
        for vehicle in results:
            print(vehicle)
        self.ui_vehicle_table_footer()

#########################################################################################################################

#Prints the search menu for vehicles

    def ui_search_menu(self):
        self.general.ui_menu_header("Vehicle Search")
        print("\nPlease select a search option:")
        self.UI_numbered_menu([
            "Manufacturer", "Model", "Vehicle type", "Status",
            "Manufacturing year", "Color", "License Requirement", "Location",
            "Exit"
        ])
        self.general.ui_menu_footer()
        selection = input("\n>> Select option: ")
        return selection

    #Prints any UI menu in order
    def UI_numbered_menu(self, a_list):
        '''Takes a list as parameter and prints all the items of a list in an order from 1. list[0], 2. list[1] and so on'''
        for i in range(0, (len(a_list))):
            print(f"{i+1}. {a_list[i]}")

    def ui_country_available_print(self):
        '''Prints all destination type categories'''
        print("\nAvailable Options:")
        destinations = self.logic.available_country()
        for destination in destinations:
            print("\t" + destination)
        print()
        return destinations

    #Prints the Vehicle Main Menu
    def vehicle_menu(self):
        while True:
            self.general.ui_menu_header("Vehicle Menu")
            print(
                "\nSelect an option...\n1. Create new vehicle \n2. Search vehicles \n3. Check availability \n4. Check in/check out vehicle. \n5. View all vehicles \n6. Edit vehicle \n7. Delete vehicle \n8. Main Menu"
            )
            self.general.ui_menu_footer()
            command = input(">> Select option: ")
            command = command.lower()
            if command == "1":
                new_vehicle = self.ui_new_vehicle()
                self.logic.create_vehicle(*new_vehicle)
            elif command == "2":
                selection = self.ui_search_menu()
                if selection == "1":
                    self.ui_print_manufacturer()
                elif selection == "2":
                    self.ui_print_model()
                elif selection == "3":
                    self.ui_print_vehicle_type()
                elif selection == "4":
                    self.ui_print_status()
                elif selection == "5":
                    self.ui_print_manufacturing_year()
                elif selection == "6":
                    self.ui_print_color()
                elif selection == "7":
                    self.ui_print_license_type()
                elif selection == "8":
                    self.ui_print_location()
                elif selection == "9":
                    self.vehicle_menu()
            elif command == "3":
                self.ui_all_vehicles()
            elif command == "4":
                self.ui_checkin_menu()
            elif command == "5":
                self.ui_all_vehicles()
            elif command == "6":
                new_vehicle = self.ui_edit_vehicle()
                self.logic.edit_vehicle(new_vehicle)
            elif command == "7":
                vehicle_id = input(">> Enter vehicle ID to delete: ")
                vehicle = self.logic.delete_vehicle(vehicle_id)
                for result in vehicle:
                    print(result)
            elif command == "8":
                return
            else:
                print("Invalid command, try again")

    def ui_checkin_menu(self):
        self.general.ui_menu_header('Check-in Menu')
        print(
            "Select an option...\n1.Check out vehicle.\n2.Check in vehicle.\n3.Return."
        )
        self.general.ui_menu_footer()
        choice = input(">> Select option: ")
        if choice == '3':
            return
        elif choice == '1':
            vehicle = input("Enter contract ID: ")
            print(self.logic.vehicle_check_out(vehicle))
        elif choice == '2':
            vehicle = input("Enter contract ID: ")
            print(self.logic.vehicle_check_in(vehicle))
        elif choice == '3':
            return
コード例 #12
0
 def __init__(self):
     self.logic = LogicAPI()
     self.login()
コード例 #13
0
class UIMain:
    promt_login = True

    def __init__(self):
        self.logic = LogicAPI()
        self.login()

        #Menu header
    def ui_menu_header(self, menu_name):
        print(" _   _       _   _            _      _ _                  ")
        print("| \ | |     | \ | |     /\   (_)    | (_)                 ")
        print("|  \| | __ _|  \| |    /  \   _ _ __| |_ _ __   ___  ___  ")
        print("| . ` |/ _` | . ` |   / /\ \ | | '__| | | '_ \ / _ \/ __| ")
        print("| |\  | (_| | |\  |  / ____ \| | |  | | | | | |  __/\__ \ ")
        print("|_| \_|\__,_|_| \_| /_/    \_\_|_|  |_|_|_| |_|\___||___/ ")
        print()
        print("-" * 20 + f"{menu_name}" + "-" * 20)

    #Menu footer
    def ui_menu_footer(self):
        print("-" * 50)

    def login(self):
        self.ui_menu_header("Please Login")
        while self.promt_login == True:
            print('\nPress "q" to exit')
            print()
            employee_id = input(">> Employee ID: ")
            if employee_id == "q":
                break
            password = input(">> Password: "******"\n*** INVALID PASSWORD AND/OR USERNAME ***\n")
            else:
                if employee_role == "OFFICE":
                    self.office_ui_loop()
                elif employee_role == "AIRPORT":
                    self.airport_ui_loop()
                elif employee_role == "ADMIN":
                    self.admin_ui_loop()

    def admin_ui_loop(self):
        while True:
            self.ui_menu_header("Main Menu")
            print(
                "\nSelect an option...\n1. Vehicles \n2. Customers \n3. Contracts \n4. Reports \n5. Destinations \n6. Employees \n7. Invoices \nq. Quit program\n"
            )
            self.ui_menu_footer()
            command = input("Input your command: ")
            command = command.lower()
            if command == "1":
                self.vehicle = VehicleUI()
            elif command == "2":
                self.customer = CustomerUI()
            elif command == "3":
                self.contracts = ContractUI()
            elif command == "4":
                self.report = ReportUI()
            elif command == "5":
                self.destination = destinationUI()
            elif command == "6":
                self.employee = EmployeeUI()
            elif command == '7':
                self.invoice = InvoiceUI()
            elif command == "q":
                self.promt_login = False
                return
            else:
                print("Invalid command, try again")

    def airport_ui_loop(self):
        while True:
            self.ui_menu_header("Main Menu")
            print(
                "\nSelect an option...\n1. Vehicles \n2. Customers \nq. Quit program\n"
            )
            self.ui_menu_footer()
            command = input("Input your command: ")
            command = command.lower()
            if command == "1":
                self.vehicle = VehicleUI()
            elif command == "2":
                self.customer = CustomerUI()
            elif command == "q":
                self.promt_login = False
                return
            else:
                print("Invalid command, try again")

    def office_ui_loop(self):
        while True:
            self.ui_menu_header("Main Menu")
            print(
                "\nSelect an option...\n1. Contracts \n2. Reports \nq. Quit program\n"
            )
            self.ui_menu_footer()
            command = input("Input your command: ")
            command = command.lower()
            if command == "1":
                self.contracts = ContractUI()
            elif command == "2":
                self.report = ReportUI()
            elif command == "q":
                self.promt_login = False
                return
            else:
                print("Invalid command, try again")
コード例 #14
0
from models.contracts import Contract
from models.Customers import Customer
from models.Destinations import Destination
from models.Employee import Employee
from models.Vehicle import Vehicle
from models.Invoice import Invoice
from models.rates import Rate
from data.dataAPI import dataAPI
from logic.logicAPI import LogicAPI

import datetime
x = datetime.datetime.today()
current_time = x.strftime('%d-%b %Y')

test = dataAPI()
logic = LogicAPI()
#unique_id, customer, vehicle_unique_id, start_date, end_date, country, employee, total_price, contract_creation_date, state

contract = Contract('', 'customer', 'customer_ssn', 'vehicle_unique_id',
                    'start_date', 'end_date', 'country', 'employee',
                    'total_price', 'contract_creation_date', 'checkout_date',
                    'checkin_date', 'checkin_location', 'state')
# customer = Customer("4", "John Smith", "150588-2459", "Heimilisgata 1", "TEST", "Reykjavik", "Iceland", "551-4489", "*****@*****.**")
# destination = Destination("2", "Iceland", "TEST", "Keflavik Airport", "558-5498", "10:00", "15:00", "Contact")
employee = Employee("", "Jon Jonsson", "150589-2129", "City staff", "TEST 50",
                    "105", "Reykjavik", "Iceland", "551-4469", "889-2121",
                    "*****@*****.**")
# car = Vehicle("40", "Benz", "Model-s", "Sportscar", "OK", "2020", "Panther Black", "Drivers License", "TEST")
# def validate(date_text):
#         try:
#             datetime.datetime.strptime(date_text, '%d.%m.%y')
コード例 #15
0
ファイル: EmployeeUI.py プロジェクト: raggiok/VLN1
class EmployeeUI:
    def __init__(self):
        self.general = GeneralUI()
        self.logicAPI = LogicAPI()
        self.employee_menu()

    #unique_id,name,ssn,role,address,zip_code,city,country,home_phone,mobile_phone,email,state
    #create new employee
    def ui_new_employee(self):
        employeeFieldnames = [
            "Name", "Social security number", "Role", "Address", "Zip Code",
            "City", "Country", "Home phone", "Mobile phone", "Email",
            "Password"
        ]
        inputList = []
        print("\nPress 'q' and hit 'enter' to cancel at any time.")
        print("\nPlease enter the following details to create a new employee:")
        user_input = ""
        for field in employeeFieldnames:
            if user_input.lower() == "q":
                return
            if field == "Password":
                user_input = self.logicAPI.generate_password()
            else:
                user_input = input(f"Enter {field}: ")
            inputList.append(user_input)
        return inputList

    #Request new value from user
    def value_input(self):
        return input("Enter new value: ")

    #Creates the Edit menu layout and returns the employee Instance after edit
    def ui_edit_employee(self):
        employee = self.ui_single_employee_unique()  #prints specific employee
        selection = ""
        while selection != "11":
            self.ui_print_edit_menu()  #ask user what he would like to edit
            selection = self.general.ui_edit_input()
            if selection == "1":
                employee.name = self.value_input()
            elif selection == "2":
                employee.ssn = self.value_input()
            elif selection == "3":
                employee.role = self.value_input()
            elif selection == "4":
                employee.address = self.value_input()
            elif selection == "5":
                employee.zip_code = self.value_input()
            elif selection == "6":
                employee.city = self.value_input()
            elif selection == "7":
                employee.country = self.value_input()
            elif selection == "8":
                employee.home_phone = self.value_input()
            elif selection == "9":
                employee.mobile_phone = self.value_input()
            elif selection == "10":
                employee.email = self.value_input()
            elif selection == "11":
                return employee

    #unique_id	name	ssn	role	address	zip_code	city	country	home_phone	mobile_phone	email	state
    #Prints the employee Edit menu options
    def ui_print_edit_menu(self):
        '''Prints options for Edit menu and accepts input'''
        self.general.ui_menu_header("Edit employee")
        print("\nSelect field to edit:")
        print("1. Name")
        print("2. SSN")
        print("3. Role")
        print("4. Address")
        print("5. Zip_code")
        print("6. City")
        print("7. Country")
        print("8. Home_phone")
        print("9. Mobile_phone")
        print("10. Email")
        print("11. Exit")
        self.general.ui_menu_footer()

    #Print Employee Table Header
    def ui_employee_table_header(self):
        print(
            f"{'Unique_id':<20}{'Name':<20}{'SSN':<20}{'Role':<20}{'Address':<20}{'Zip_code':<20}{'City':<20}{'Country':<20}{'Home_phone':<20}{'Mobile_phone':<20}{'Email':<20}"
        )
        print("-" * 200)

    #Print employee Table Footer
    def ui_employee_table_footer(self):
        print("-" * 200)
        print()

    #Prints all employee
    def ui_all_employee(self):
        results = self.logicAPI.get_employees()
        print("\nAll employee:")
        self.ui_employee_table_header()
        for employee in results:
            print(employee)
        self.ui_employee_table_footer()

    #Prints customer with unique ID
    def ui_single_employee_unique(self):
        '''Prints a single customer with a unique ID'''
        employee_unique = input(">> Please enter employee ID: ")
        employees = self.logicAPI.search_employee_by_unique(employee_unique)
        print("\ncustomer by ID: " + employee_unique)
        self.ui_employee_table_header()
        for employee in employees:
            print(employee)
        self.ui_employee_table_footer()
        return employee

    #name	ssn	role	address	zip_code	city	country	home_phone	mobile_phone	email	state
    ###availability option search ###
    def ui_name_available_print(self):
        '''Prints all employee name'''
        print("\nAvailable Options:")
        employees = self.logicAPI.available_name()
        for employee in employees:
            print("\t" + employee)
        print()

    def ui_ssn_available_print(self):
        '''Prints all customer SSN'''
        print("\nAvailable Options:")
        employees = self.logicAPI.available_ssn()
        for employee in employees:
            print("\t" + employee)
        print()

    def ui_role_available_print(self):
        '''Prints all employee role'''
        print("\nAvailable Options:")
        employees = self.logicAPI.available_role()
        for employee in employees:
            print("\t" + employee)
        print()

    def ui_address_available_print(self):
        '''Prints all employee address'''
        print("\nAvailable Options:")
        employees = self.logicAPI.available_address()
        for employee in employees:
            print("\t" + employee)
        print()

    def ui_zip_code_available_print(self):
        '''Prints all employee zip_code'''
        print("\nAvailable Options:")
        employees = self.logicAPI.available_zip_code()
        for employee in employees:
            print("\t" + employee)
        print()

    def ui_city_available_print(self):
        '''Prints all employee city'''
        print("\nAvailable Options:")
        employees = self.logicAPI.emp_available_city()
        for employee in employees:
            print("\t" + employee)
        print()

    def ui_country_available_print(self):
        '''Prints all employee country'''
        print("\nAvailable Options:")
        employees = self.logicAPI.emp_available_country()
        for employee in employees:
            print("\t" + employee)
        print()

    #name	ssn	role	address	zip_code	city	country
    #Print the availability data
    def ui_print_country(self):
        self.ui_country_available_print()
        country = input(">> Please enter employee Country: ")
        results = self.logicAPI.search_employees_by_country(country)
        print("\nSearch results for " + country + ": ")
        self.ui_employee_table_header()
        for employee in results:
            print(employee)
        self.ui_employee_table_footer()

    def ui_print_city(self):
        self.ui_city_available_print()
        city = input(">> Please enter employee City: ")
        results = self.logicAPI.search_employees_by_city(city)
        print("\nSearch results for " + city + ": ")
        self.ui_employee_table_header()
        for employee in results:
            print(employee)
        self.ui_employee_table_footer()

    def ui_print_zip_code(self):
        self.ui_zip_code_available_print()
        zip_code = input(">> Please enter employee zip_code: ")
        results = self.logicAPI.search_employees_by_zip_code(zip_code)
        print("\nSearch results for " + zip_code + ": ")
        self.ui_employee_table_header()
        for employee in results:
            print(employee)
        self.ui_employee_table_footer()

    def ui_print_address(self):
        self.ui_address_available_print()
        address = input(">> Please enter employee address: ")
        results = self.logicAPI.search_employees_by_address(address)
        print("\nSearch results for " + address + ": ")
        self.ui_employee_table_header()
        for employee in results:
            print(employee)
        self.ui_employee_table_footer()

    def ui_print_role(self):
        self.ui_role_available_print()
        role = input(">> Please enter employee role: ")
        results = self.logicAPI.search_employees_by_role(role)
        print("\nSearch results for " + role + ": ")
        self.ui_employee_table_header()
        for employee in results:
            print(employee)
        self.ui_employee_table_footer()

    def ui_print_ssn(self):
        self.ui_ssn_available_print()
        ssn = input(">> Please enter employee ssn: ")
        results = self.logicAPI.search_employees_by_id(ssn)
        print("\nSearch results for " + ssn + ": ")
        self.ui_employee_table_header()
        for employee in results:
            print(employee)
        self.ui_employee_table_footer()

    def ui_print_name(self):
        self.ui_name_available_print()
        name = input(">> Please enter employee name: ")
        results = self.logicAPI.search_employees_by_name(name)
        print("\nSearch results for " + name + ": ")
        self.ui_employee_table_header()
        for employee in results:
            print(employee)
        self.ui_employee_table_footer()

    #name	ssn	role	address	zip_code	city	country
    #Prints the search menu for employee
    def ui_search_menu(self):
        self.general.ui_menu_header("Employee Search")
        print("\nPlease select a search option:")
        self.UI_numbered_menu([
            "Name", "Social Security Number", "Role", "Address", "Zip Code",
            "City", "Country", "Exit"
        ])
        #self.UI_numbered_menu([ "ID", "Role", "Exit"])
        self.general.ui_menu_footer()
        selection = input("\n>> Select option: ").lower()
        return selection

    #Prints any UI menu in order
    def UI_numbered_menu(self, a_list):
        '''Takes a list as parameter and prints all the items of a list in an order from 1. list[0], 2. list[1] and so on'''
        for i in range(0, (len(a_list))):
            print(f"{i+1}. {a_list[i]}")

    #name	ssn	role	address	zip_code	city	country
    #Prints the employee Main Menu
    def employee_menu(self):
        while True:
            self.general.ui_menu_header("Employee Menu")
            print(
                "\nSelect an option...\n1. Create new employee \n2. Search employees  \n3. View all employees \n4. Edit employee \n5. Delete employee \n6. Main Menu"
            )
            self.general.ui_menu_footer()
            command = input(">> Select option: ")
            command = command.lower()
            if command == "1":
                new_employee = self.ui_new_employee()
                self.logicAPI.create_employee(new_employee)
            elif command == "2":
                selection = self.ui_search_menu()
                if selection == "1":
                    self.ui_print_name()
                elif selection == "2":
                    self.ui_print_ssn()
                elif selection == "3":
                    self.ui_print_role()
                elif selection == "4":
                    self.ui_print_address()
                elif selection == "5":
                    self.ui_print_zip_code()
                elif selection == "6":
                    self.ui_print_city()
                elif selection == "7":
                    self.ui_print_country()
                elif selection == "8":
                    self.employee_menu()
            elif command == "3":
                self.ui_all_employee()
            elif command == "4":
                new_employee = self.ui_edit_employee()
                self.logicAPI.update_employee(new_employee)
            elif command == "5":
                self.ui_all_employee()
                employee_id = input(">> Enter employee ID to delete: ")
                employee = self.logicAPI.delete_employee(employee_id)
                for result in employee:
                    print(result)
            elif command == "6":
                return
            else:
                print("Invalid command, try again")
コード例 #16
0
ファイル: EmployeeUI.py プロジェクト: raggiok/VLN1
 def __init__(self):
     self.general = GeneralUI()
     self.logicAPI = LogicAPI()
     self.employee_menu()
コード例 #17
0
ファイル: CustomerUI.py プロジェクト: raggiok/VLN1
 def __init__(self):
     self.general = GeneralUI()
     self.logicAPI = LogicAPI()
     self.customer_menu()