Ejemplo n.º 1
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")
Ejemplo n.º 2
0
# 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')
#         except ValueError:
#             print("Incorrect data format, should be DD.MM.YY")

#test.create_employee(employee)
unique_id = "6"
password = "******"

test = logic.check_password(unique_id, password)
for i in test:
    print(i)

#test.create_employee(employee)

# for item in test.get_contracts():
#     print(item)

# for item in test.get_customers():
#     print(item)

# for item in test.get_destinations():
#     print(item)

# for item in test.get_employees():