def handle_menu():
    options = ["Store manager",
               "Human resources manager",
               "Tool manager",
               "Accounting manager",
               "Selling manager",
               "Customer Relationship Management (CRM)"]

    ui.print_menu("Main menu", options, "Exit program")
def ask_for_data_and_update(table, id_, list_of_titles):

    ui.print_menu("What do you want to update?", list_of_titles, "Back")
    number_given = False
    while not number_given:
        try:
            to_update = int(ui.get_inputs(["Please enter a number: "], "")[0])
            if to_update > (-1) and to_update < 5:
                number_given = True
            else:
                number_given = False
        except:
            number_given = False
    if to_update != 0:
        update_to = str(ui.get_inputs(["Update data to: "], "")[0])
        for all_info in table:
            id_to_observe = "".join(all_info[0])
            if id_to_observe == id_:
                all_info[to_update] = update_to
        return table
    else:
        return table
def choose_sales():
    sales_menu_active = True
    table = data_manager.get_table_from_file('hr/persons.csv')
    while sales_menu_active is True:
        inputs = ui.get_inputs(["Please enter a number: "], "")
        option = inputs[0]
        if option == '1':
            show_table(table)
            ui.print_menu('Human resources manager', [
                'Show table', 'Add', 'Remove', 'Update', 'Oldest person',
                'Persons closest to average'
            ], 'Return to main menu')
        elif option == '2':
            add(table)
            ui.print_menu('Human resources manager', [
                'Show table', 'Add', 'Remove', 'Update', 'Oldest person',
                'Persons closest to average'
            ], 'Return to main menu')
        elif option == '3':
            id_ = ui.get_inputs(['Record to be deleted: '], '')[0]
            remove(table, id_)
            data_manager.write_table_to_file('hr/persons.csv', table)
            ui.print_menu('Human resources manager', [
                'Show table', 'Add', 'Remove', 'Update', 'Oldest person',
                'Persons closest to average'
            ], 'Return to main menu')
        elif option == '4':
            id_ = ui.get_inputs(['Record to be updated: '], '')[0]
            update(table, id_)
            data_manager.write_table_to_file('hr/persons.csv', table)
            ui.print_menu('Human resources manager', [
                'Show table', 'Add', 'Remove', 'Update', 'Oldest person',
                'Persons closest to average'
            ], 'Return to main menu')
        elif option == '5':
            oldest = get_oldest_person(table)
            ui.print_result(oldest, 'Oldest person is: ')
            ui.print_menu('Human resources manager', [
                'Show table', 'Add', 'Remove', 'Update', 'Oldest person',
                'Persons closest to average'
            ], 'Return to main menu')
        elif option == '6':
            medium_age = get_persons_closest_to_average(table)
            ui.print_result(medium_age, 'Medium age person is: ')
            ui.print_menu('Human resources manager', [
                'Show table', 'Add', 'Remove', 'Update', 'Oldest person',
                'Persons closest to average'
            ], 'Return to main menu')
        elif option == '0':
            sales_menu_active = False
def start_module():
    """
    Starts this module and displays its menu.
    User can access default special features from here.
    User can go back to main menu from here.

    Returns:
        None
    """
    table = data_manager.get_table_from_file('sales/sales.csv')

    is_not_main_menu = True
    while is_not_main_menu:
        data_manager.write_table_to_file('sales/sales.csv', table)

        sales_manager_menu = [
            "(1) Show table", "(2) Add", "(3) Remove", "(4) Update",
            "(5) Get lowest price item id", "(6) Get items sold between"
        ]

        ui.print_menu("Sales manager menu: ", sales_manager_menu,
                      "(0) Back to main menu")

        inputs = ui.get_inputs(['Choose option from menu ', 9], '')
        chose_menu_number = inputs[0]

        is_menu_sales = True
        while is_menu_sales:

            if chose_menu_number == "1":
                show_table(table)
                is_menu_sales = False

            elif chose_menu_number == "2":
                add(table)
                is_menu_sales = False

            elif chose_menu_number == "3":
                remove(table, ui.get_inputs(['Enter id: ', 6],
                                            'Remove record'))
                is_menu_sales = False

            elif chose_menu_number == "4":
                update(table, ui.get_inputs(['Enter id: ', 6],
                                            'Update record'))
                is_menu_sales = False

            elif chose_menu_number == "5":
                result = get_lowest_price_item_id(table)

                ui.print_result(result, 'The id of lowest price: \n')
                is_menu_sales = False

            elif chose_menu_number == "6":
                questions_list = [
                    'Enter initial month ', 4, 'Enter initial day ', 5,
                    'Enter initial year ', 3, 'Enter final month ', 4,
                    'Enter final day ', 5, 'Enter final year ', 3
                ]

                inputs_list = ui.get_inputs(questions_list, 'Enter a time')
                result = get_items_sold_between(table, inputs_list[0],
                                                inputs_list[1], inputs_list[2],
                                                inputs_list[3], inputs_list[4],
                                                inputs_list[5])
                ui.print_result(result, 'Items in part of time: \n')
                is_menu_sales = False

            elif chose_menu_number == "0":
                is_menu_sales = False
                is_not_main_menu = False
def start_module():
    """
    Starts this module and displays its menu.
     * User can access default special features from here.
     * User can go back to main menu from here.

    Returns:
        None
    """
    table = data_manager.get_table_from_file("store/games.csv")

    options = [
        "Show table",
        "Add item",
        "Remove item",
        "Update item",
        "Games per manufacturer",
        "Average stock by manufacturer"]

    while True:
        ui.print_menu("- Store manager -", options, "Back to Main menu")
        option = ui.get_inputs(["Please enter a number: "], "")

        try:
            if option == "1":
                show_table(table) 
                common.go_back_in_menu()

            elif option == "2":
                table = add(table) 
                data_manager.write_table_to_file("store/games.csv", table)

            elif option == "3":
                id_to_remove = ui.get_inputs(
                    ["Please enter the ID of the title you wish to remove: "], ""
                )
                if common.check_id_in_table(table, id_to_remove):
                    table = remove(table, id_to_remove)
                    data_manager.write_table_to_file("store/games.csv", table)

            elif option == "4":
                id_to_update = ui.get_inputs(
                    ["Please enter the ID of the title you wish to update: "],
                    ""
                )
                if common.check_id_in_table(table, id_to_update): 
                    update(table, id_to_update)
                    data_manager.write_table_to_file("store/games.csv", table)

            elif option == "5":
                count_by_manufacturer = get_counts_by_manufacturers(table)
                ui.print_result(count_by_manufacturer, ["MANUFACTURER", "GAMES"])
                common.go_back_in_menu()
                
            elif option == "6":
                which_manuf = ui.get_inputs(
                    ["Please enter which manufacturer: "],
                    ""
                )
                try:
                    average_stock_by_manufacturer = get_average_by_manufacturer(table, which_manuf)
                except ZeroDivisionError:
                    continue

                ui.print_result(average_stock_by_manufacturer,"The avarege stock by the manufacturer is ")
                common.go_back_in_menu()

            elif option == "0":
                break

            else:
                raise KeyError("There is no such option")

        except KeyError as err:
            ui.print_error_message(str(err))
Exemplo n.º 6
0
def start_module():
    """
    Starts this module and displays its menu.
     * User can access default special features from here.
     * User can go back to main menu from here.

    Returns:
        None
    """

    table = data_manager.get_table_from_file("sales/sales.csv")
    list_options = ["Show table", "Add new record", "Remove record",
                    "Update record", "Lowest price item", "Items sold in given time", "Get title by ID",
                    "Get item ID sold last", "Get item title sold last", "Get the sum of prices", "Get customer ID by sale ID",
                    "Get all customers ID", "get all sale ID", "Get number of sales per customer"]
    while True:
        ui.print_menu("Sales manager", list_options, "Back to main menu")
        inputs = ui.get_inputs(["Please enter a number: "], "")
        option = inputs[0]
        if option == "1":
            show_table(table)
        elif option == "2":
            add(table)
        elif option == "3":
            id_ = ui.get_inputs(["ID: "], "Please type ID to remove")
            table = remove(table, id_)
        elif option == "4":
            id_ = ui.get_inputs(["ID: "], "Please type ID to update")
            table = update(table, id_)
        elif option == "5":
            ui.print_result(get_lowest_price_item_id(table),
                            "The id of the item sold for the lowest price is")
        elif option == "6":
            month_from = ui.get_inputs(["Month from: "], "")
            day_from = ui.get_inputs(["Day from: "], "")
            year_from = ui.get_inputs(["Year from: "], "")
            month_to = ui.get_inputs(["Month to: "], "")
            day_to = ui.get_inputs(["Day to: "], "")
            year_to = ui.get_inputs(["Year to: "], "")
            ui.print_result(get_items_sold_between(table, month_from, day_from, year_from, month_to,
                                                   day_to, year_to), "The list with the items sold in the chosen amount of time is")
        elif option == "7":
            id_ = ui.get_inputs(["ID: "], "Please type ID:")
            ui.print_result(get_title_by_id_from_table(
                table, id_), "The title is:")
        elif option == "8":
            ui.print_result(get_item_id_sold_last_from_table(
                table), "The last id item sold is:")

        elif option == "9":
            ui.print_result(get_item_title_sold_last_from_table(
                table), "The last id item sold is:")

        elif option == "10":
            item_idss = [1, 1]
            item_ids = []
            while item_idss[1] == True:
                item_idss = ui.get_inputs(
                    ["ID:", "add another one?:"], "introduce ID")
                item_ids.append(item_idss[0])
            ui.print_result(get_the_sum_of_prices_from_table(
                table, item_ids), "The sum of items is:")
        elif option == "11":
            sale_id = ui.get_inputs(["ID:"], "introduce ID")
            ui.ptint_result(
                get_customer_id_by_sale_id_from_table(table, sale_id), "ID sale is:")
        elif option == "12":
            ui.print_result(get_all_customer_ids_from_table(
                table), "All customer ids is:")
        elif option == "13":
            ui.print_result(
                get_all_sales_ids_for_customer_ids_from_table(table), "All sales IDs is:")
        elif option == "14":
            ui.print_result(
                get_num_of_sales_per_customer_ids_from_table(table), "All sales per customer are:")
        elif option == "0":
            break
        else:
            ui.print_error_message("Choose something else!")
Exemplo n.º 7
0
def start_module():
    """
    Starts this module and displays its menu.
     * User can access default special features from here.
     * User can go back to main menu from here.

    Returns:
        None
    """
    common.clear()
    special_functions = [
        "Show table", "Add elements", "Remove element by it's ID",
        "Update an element", "Get oldest person",
        "Get person whose closest to averege"
    ]

    table = data_manager.get_table_from_file("hr/persons_test.csv")
    ui.print_menu("Human Resources Manager MENU", special_functions,
                  "go back to Main Menu.")
    choice = ui.get_inputs(" ", "What's your choice?")
    choice = common.check_one_input_for_number(choice, " ",
                                               "What's your choice?")

    while choice != 0:
        if choice == 1:  #show
            show_table(table)

        elif choice == 2:  #add
            add(table)
            data_manager.write_table_to_file("hr/persons_test.csv", table)

        elif choice == 3:  #remove
            id = ui.get_inputs(" ", "Add the searched ID")
            id = id[0]
            remove(table, id)
            data_manager.write_table_to_file("hr/persons_test.csv", table)

        elif choice == 4:  #update
            id = ui.get_inputs(" ", "Add the searched ID")
            id = id[0]
            update(table, id)
            data_manager.write_table_to_file("hr/persons_test.csv", table)

        elif choice == 5:  #oldest
            ui.print_result(get_oldest_person(table),
                            "The oldest persons are:")

        elif choice == 6:  #closest to avg
            result = avg_amount(table, year)
            ui.print_result(result, "The person closest to average is:")

        else:
            ui.print_error_message("Wrong input!")

        ui.print_menu("Human Resources Manager MENU", special_functions,
                      "go back to Main Menu.")
        choice = ui.get_inputs(" ", "What's your choice?")
        choice = common.check_one_input_for_number(choice, " ",
                                                   "What's your choice?")
        common.clear()

    common.clear()
Exemplo n.º 8
0
def handle_menu():
    options = ["show table", "add", "remove", "update"]

    ui.print_menu("\nStore manager", options, "back to the main menu")
Exemplo n.º 9
0
def handle_menu():
    menu = ["Create application", "Update application", "Delete application"]
    menu_name = "Application menu:"
    ui.print_menu(menu, menu_name)
Exemplo n.º 10
0
def Show_menu():
    options = [
        "Create Application", "Update Application", "Delete Application",
        "Read Applications"
    ]
    ui.print_menu("Application menu", options, "Back to main menu")
Exemplo n.º 11
0
def handle_menu():
    options = ["Student", "Company", "Position", "Application"]

    ui.print_menu("Main menu", options, "Exit")
def choose_crm(crm_menu_list):
    crm_menu_active = True
    while crm_menu_active is True:
        inputs = ui.get_inputs(["Please enter a number: "], "")
        option = inputs[0]
        table = data_manager.get_table_from_file('crm/customers.csv')
        if option == '1':
            show_table(table)
            ui.print_menu('CRM', crm_menu_list, 'Return to main menu')
        elif option == '2':
            add(table)
            data_manager.write_table_to_file('crm/customers.csv', table)
            ui.print_menu('CRM', crm_menu_list, 'Return to main menu')
        elif option == '3':
            id_ = ui.get_inputs(['ID of item to remove: '], 'CRM')[0]
            table = remove(table, id_)
            data_manager.write_table_to_file('crm/customers.csv', table)
            ui.print_menu('CRM', crm_menu_list, 'Return to main menu')
        elif option == '4':
            id_ = ui.get_inputs(['ID of item to update: '], 'CRM')[0]
            update(table, id_)
            data_manager.write_table_to_file('crm/customers.csv', table)
            ui.print_menu('CRM', crm_menu_list, 'Return to main menu')
        elif option == '5':
            longest_name = get_longest_name_id(table)
            ui.print_result(
                longest_name, 'CRM data - the customer ID with the'
                ' longest name: ')
            ui.print_menu('CRM', crm_menu_list, 'Return to main menu')
        elif option == '6':
            subscribers_list = get_subscribed_emails(table)
            get_subscribed_emails(table)
            ui.print_result(subscribers_list, 'CRM data - subscribers list: ')
            ui.print_menu('CRM', crm_menu_list, 'Return to main menu')
        elif option == '7':
            id = ui.get_inputs(['customer ID: '], 'Please enter ')[0]
            ui.print_result(get_name_by_id(id), f'Customer name for ID {id}: ')
        elif option == '8':
            id = ui.get_inputs(['customer ID: '], 'Please enter ')[0]
            ui.print_result(get_name_by_id_from_table(table, id),
                            f'Customer name for ID {id}: ')
        elif option == '0':
            crm_menu_active = False
Exemplo n.º 13
0
def start_module():
    """
    Starts this module and displays its menu.
     * User can access default special features from here.
     * User can go back to main menu from here.

    Returns:
        None
    """

    table = data_manager.get_table_from_file("crm/customers.csv")

    options = [
        "Show table",
        "Add item",
        "Remove item",
        "Update item",
        "ID of the longest name",
        "Customers subscribed to newsletter"
    ]

    while True:
        ui.print_menu("- CRM manager -", options, "Back to Main menu")
        option = ui.get_inputs(["Please enter a number: "], "")

        try:
            if option == "1":
                show_table(table)
                common.go_back_in_menu()

            elif option == "2":
                table = add(table)
                data_manager.write_table_to_file("crm/customer.csv", table)

            elif option == "3":
                id_to_remove = ui.get_inputs(
                    ["Please enter the ID of the person you wish to remove: "],
                    ""
                )
                if common.check_id_in_table(table, id_to_remove):
                    table = remove(table, id_to_remove)
                    data_manager.write_table_to_file("crm/customers.csv", table)

            elif option == "4":
                id_to_update = ui.get_inputs(
                    ["Please enter the ID of the person you wish to update: "],
                    ""
                )
                if common.check_id_in_table(table, id_to_update):
                    update(table, id_to_update)
                    data_manager.write_table_to_file("crm/customers.csv", table)

            elif option == "5":
                ui.print_result(get_longest_name_id(table), "\nThe ID of the longest name is: ")
                common.go_back_in_menu()
            
            elif option == "6":
                ui.print_result(get_subscribed_emails(table), "")
                common.go_back_in_menu()
            elif option == "0":
                break

            else:
                raise KeyError("There is no such option")

        except KeyError as err:
            ui.print_error_message(str(err))
Exemplo n.º 14
0
def handle_menu():
    options = ["Show all", "Add", "Remove", "Update", "Show manufacturers"]
    menu_title = "Store module"
    exit_message = "Back to main menu"
    ui.print_menu(menu_title, options, exit_message)
Exemplo n.º 15
0
def choose_requests():
    requests_menu_active = True
    while requests_menu_active is True:
        valid_command = False
        while valid_command is False:
            try:
                inputs = ui.get_inputs(["Please enter a number: "], "")
                if inputs[0].isdigit() is False:
                    raise ValueError
                if int(inputs[0]) in range(0, 7):
                    valid_command = True
                elif inputs[0] not in range(0, 7):
                    raise ValueError
            except ValueError:
                ui.print_error_message('Invalid command. Please choose '
                                       'between 0 and 6.')
        option = inputs[0]
        table = data_manager.get_table_from_file(
            'cst_requests/cst_requests.csv')
        if option == '1':
            show_table(table)
            ui.print_menu('Requests', [
                'Show table', 'Add', 'Remove', 'Update', 'Most requested game',
                'Oldest request'
            ], 'Return to main menu')
        elif option == '2':
            add(table)
            data_manager.write_table_to_file('cst_requests/cst_requests.csv',
                                             table)
            ui.print_menu('Requests', [
                'Show table', 'Add', 'Remove', 'Update', 'Most requested game',
                'Oldest request'
            ], 'Return to main menu')
        elif option == '3':
            remove_id_ = ui.get_inputs(['ID of item to remove: '],
                                       'Requests')[0]
            remove(table, remove_id_)
            data_manager.write_table_to_file('cst_requests/cst_requests.csv',
                                             table)
            ui.print_menu('Requests', [
                'Show table', 'Add', 'Remove', 'Update', 'Most requested game',
                'Oldest request'
            ], 'Return to main menu')
        elif option == '4':
            update_id_ = ui.get_inputs(['ID of item to update: '],
                                       'Requests')[0]
            update(table, update_id_)
            data_manager.write_table_to_file('cst_requests/cst_requests.csv',
                                             table)
            ui.print_menu('Requests', [
                'Show table', 'Add', 'Remove', 'Update', 'Most requested game',
                'Oldest request'
            ], 'Return to main menu')
        elif option == '5':
            most_requested_list = most_requested(table)
            ui.print_table(most_requested_list,
                           ['ID', 'title', 'developer', 'year of request'])
            ui.print_menu('Requests', [
                'Show table', 'Add', 'Remove', 'Update', 'Most requested game',
                'Oldest requested game'
            ], 'Return to main menu')
        elif option == '6':
            oldest_requested_game = oldest_request(table)
            ui.print_table(oldest_requested_game,
                           ['ID', 'title', 'developer', 'year of request'])
            ui.print_menu('Requests', [
                'Show table', 'Add', 'Remove', 'Update', 'Most requested game',
                'Oldest request'
            ], 'Return to main menu')
        elif option == '0':
            requests_menu_active = False
def start_module():
    while True:
        datas = data_manager.get_table_from_file("sales/sales.csv")
        options = [
            "Display table",
            "Add",
            "Remove",
            "Update",
            "The ID of the item sold for the lowest price",
            "Items that are sold between two given dates",
            "Get the title of the item by ID",
            "Get the title of the item by ID from table",
            "Get the ID of the item sold last",
            "Get the ID of the item sold last from table",
            "Get the title of the item sold last from table",
            "Get the sum of prices of the given item IDs",
            "Get the sum of prices of the given item IDs from table",
            "Get the customer ID by the given sale ID",
            "Get the customer ID by the given sale ID from table",
            "Get all customer IDs",
            "Get all customer IDs from table",
            "Get all sales IDs for the customer IDs",
            "Get all sales IDs for the customer IDs from table",
            "Get the number of sales per customer IDs",
            "Get the number of sales per customer IDs from table"]
        ui.print_menu("\nSales menu", options, "Main menu")
        inputs = ui.get_inputs(["Please, choose an option: "], "")
        option = inputs[0]
        if option == "1":
            os.system("clear")
            show_table(datas)
        elif option == "2":
            os.system("clear")
            add(datas)
            write_to_file(datas)
        elif option == "3":
            os.system("clear")
            given_id = ui.get_inputs(["Please, enter an ID to remove the line: "], "")
            remove(datas, given_id)
            write_to_file(datas)
        elif option == "4":
            os.system("clear")
            update_id = ui.get_inputs(["Please, enter an ID to update the line: "], "")
            update(datas, update_id)
            write_to_file(datas)
        elif option == "5":
            os.system("clear")
            ui.print_result(get_lowest_price_item_id(datas), "The ID of the item sold for the lowest price:")
        elif option == "6":
            os.system("clear")
            date_list = ui.get_inputs(["Month from: ", "Day from: ", "Year from: ",
                                       "Month to: ", "Day to: ", "Year to: "], "Please, add the dates!")
            ui.print_result(
                get_items_sold_between(
                    datas, int(
                        date_list[0]), int(
                        date_list[1]), int(
                        date_list[2]), int(
                        date_list[3]), int(
                            date_list[4]), int(
                                date_list[5])), "Items that are sold between two given dates:\n")
        elif option == "7":
            os.system("clear")
            given_id = ui.get_inputs(["Please, enter an ID to get the title: "], "")
            ui.print_result(get_title_by_id(given_id[0]), "The title of the item by ID:")
        elif option == "8":
            os.system("clear")
            given_id = ui.get_inputs(["Please, enter an ID to get the title: "], "")
            ui.print_result(get_title_by_id_from_table(datas, given_id[0]), "The title of the item by ID:")
        elif option == "9":
            os.system("clear")
            ui.print_result(get_item_id_sold_last(), "The ID of the item sold last:")
        elif option == "10":
            os.system("clear")
            ui.print_result(get_item_id_sold_last_from_table(datas), "The ID of the item sold last:")
        elif option == "11":
            os.system("clear")
            ui.print_result(get_item_title_sold_last_from_table(datas), "The title of the item sold last:")
        elif option == "12":
            os.system("clear")
            given_ids = ui.get_inputs(
                ["Please, enter the IDs (seperated by comma) to get the sum of the prices of the items: "], "")
            splitted_given_ids = given_ids[0].split(",")
            ui.print_result(get_the_sum_of_prices(splitted_given_ids), "The sum of prices of the given item IDs:")
        elif option == "13":
            os.system("clear")
            given_ids = ui.get_inputs(
                ["Please, enter the IDs (seperated by comma) to get the sum of the prices of the items: "], "")
            splitted_given_ids = given_ids[0].split(",")
            ui.print_result(
                get_the_sum_of_prices_from_table(
                    datas,
                    splitted_given_ids),
                "The sum of prices of the given item IDs:")
        elif option == "14":
            os.system("clear")
            given_id = ui.get_inputs(["Please, enter the sale ID to get the customer ID: "], "")
            ui.print_result(get_customer_id_by_sale_id(given_id[0]), "The customer ID by the given sale ID:")
        elif option == "15":
            os.system("clear")
            given_id = ui.get_inputs(["Please, enter the sale ID to get the customer ID: "], "")
            ui.print_result(
                get_customer_id_by_sale_id_from_table(
                    datas,
                    given_id[0]),
                "The customer ID by the given sale ID:")
        elif option == "16":
            os.system("clear")
            ui.print_result(get_all_customer_ids(), "All customer IDs:")
        elif option == "17":
            os.system("clear")
            ui.print_result(get_all_customer_ids_from_table(datas), "All customer IDs:")
        elif option == "18":
            os.system("clear")
            ui.print_result(get_all_sales_ids_for_customer_ids(), "All sale IDs for the customer IDs:")
        elif option == "19":
            os.system("clear")
            ui.print_result(get_all_sales_ids_for_customer_ids_from_table(datas), "All sale IDs for the customer IDs:")
        elif option == "20":
            os.system("clear")
            ui.print_result(get_num_of_sales_per_customer_ids(), "The number of sales per customer IDs:")
        elif option == "21":
            os.system("clear")
            ui.print_result(
                get_num_of_sales_per_customer_ids_from_table(datas),
                "The number of sales per customer IDs:")
        elif option == "0":
            os.system("clear")
            break
        else:
            ui.print_error_message("There is no such option.")
Exemplo n.º 17
0
def handle_menu_account():
    options = [
        "Show Table", "Add something into table",
        "Remove something from table", "Update table"
    ]
    ui.print_menu("Inventory menu", options, "Exit to main menu")
Exemplo n.º 18
0
def handle_menu():
    options = ["Show table", "Add", "Remove", "Update", "sf1", "sf2"]

    ui.print_menu("Sales manager", options, "Back to main menu")
Exemplo n.º 19
0
def start_module():
    """
    Starts this module and displays its menu.
    User can access default special features from here.
    User can go back to main menu from here.

    Returns:
        None
    """
    while True:
        users = data_manager.get_table_from_file("store/password.csv")
        ui.print_menu("Store", [
            "show_table", "add", "remove", "update", "login",
            "manufacturer count", "stock avarage"
        ], "Go back to main menu")
        menu_choose_list = ui.get_inputs(["Choose: "], "")
        menu_choose = int(menu_choose_list[0])
        if menu_choose == 1:
            os.system('clear')
            show_table(the_list)
            menu_list.remove("id")
            ui.get_inputs(["Press a button: "], "")
            os.system('clear')
        elif menu_choose == 2:
            os.system('clear')
            try:
                if Login:
                    add(the_list)
            except NameError:
                ui.print_error_message(
                    "\nYou don't have permission to do that!\nPlease login first!\n"
                )
        elif menu_choose == 3:
            os.system('clear')
            try:
                if Login:
                    show_table(the_list)
                    menu_list.remove("id")
                    id = ui.get_inputs(["ID: "], "Please enter an id: ")
                    id = id[0]
            except NameError:
                ui.print_error_message(
                    "\nYou don't have permission to do that!\nPlease login first!\n"
                )
        elif menu_choose == 4:
            os.system('clear')
            try:
                if Login:
                    show_table(the_list)
                    menu_list.remove("id")
                    id = ui.get_inputs(["ID: "], "Please enter an id: ")
                    id = id[0]
                    update(the_list, menu_list, id)
            except NameError:
                ui.print_error_message(
                    "\nYou don't have permission to do that!\nPlease login first!\n"
                )
        elif menu_choose == 5:
            os.system('clear')
            Logged = common.username_pass(users, e_mail)
            if Logged == True:
                print("You logged in succesfully.")
                Login = True
            else:
                common.new_password_request(Logged, users,
                                            "strore/password.csv")
        elif menu_choose == 6:
            os.system('clear')
            ui.print_result(get_counts_by_manufacturers(the_list),
                            "Games by manufacturer:")
        elif menu_choose == 7:
            os.system('clear')
            manufacturer_input = ui.get_inputs(
                ["Enter a manufacturer name : "], "The avarage game in stock")
            manufacturer_input = manufacturer_input[0]
            ui.print_result(
                get_average_by_manufacturer(the_list, manufacturer_input),
                "The avarage games in stock:")
        elif menu_choose == 0:
            os.system('clear')
            if ui.get_inputs(["Please enter yes or no: "],
                             "Do you want to save your changes? ")[0] == "yes":
                data_manager.write_table_to_file("store/games.csv", the_list)
            return
Exemplo n.º 20
0
def start_module():
    """
    Starts this module and displays its menu.
     * User can access default special features from here.
     * User can go back to main menu from here.

    Returns:
        None
    """

    # your code
    table = data_manager.get_table_from_file(filename)
    while True:
        options = ["Show table",
                   "Add",
                   "Remove",
                   "Update",
                   "Get lowest price item",
                   "Items sold in given time range"]
        ui.print_menu("Sales Menagement menu", options, "Exit menu")
        inputs = ui.get_inputs(["Please enter a number: "], "")
        option = inputs[0]
        if option == "1":
            show_table(table)
        elif option == "2":
            table = add(table)
        elif option == "3":
            show_table(table)
            id_is_correct = 0
            while id_is_correct == 0:
                id_ = ui.get_inputs(["Index to remove:"],
                                    "Please select index from table above")
                id_ = ''.join(str(e) for e in id_)
                for games in table:
                    if games[game_id] == id_:
                        table = remove(table, id_)
                        id_is_correct += 1
                if id_is_correct == 0:
                    ui.print_error_message("ID not in list")
        elif option == "4":
            show_table(table)
            id_is_correct = 0
            while id_is_correct == 0:
                id_ = ui.get_inputs(["Index to remove:"],
                                    "Please select index from table above")
                id_ = ''.join(str(e) for e in id_)
                for games in table:
                    if games[game_id] == id_:
                        table = update(table, id_)
                        id_is_correct += 1
                if id_is_correct == 0:
                    ui.print_error_message("ID not in list")
        elif option == "5":
            ui.print_result(get_lowest_price_item_id(
                table), "Lowest price game index:\n")
        elif option == "6":
            correct_input = 0
            while correct_input == 0:
                month_from = ui.get_inputs(["Month from: "], "Provide data")
                month_from = int(''.join(str(e) for e in month_from))
                day_from = ui.get_inputs(["Day from: "], "Provide data")
                day_from = int(''.join(str(e) for e in day_from))
                year_from = ui.get_inputs(["Year from: "], "Provide data")
                year_from = int(''.join(str(e) for e in year_from))
                month_to = ui.get_inputs(["Month to: "], "Provide data")
                month_to = int(''.join(str(e) for e in month_to))
                day_to = ui.get_inputs(["Day to: "], "Provide data")
                day_to = int(''.join(str(e) for e in day_to))
                year_to = ui.get_inputs(["Year to: "], "Provide data")
                year_to = int(''.join(str(e) for e in year_to))
                if month_from and month_to in range(1, 13):
                    if day_from and day_to in range(1, 32):
                        if year_from and year_to in range(1990, 2021):
                            ui.print_table(get_items_sold_between(table, month_from, day_from, year_from, month_to,
                                                                  day_to, year_to), title_list)
                            correct_input += 1
                else:
                    ui.print_error_message(
                        "Provide correct data: months 1->12, days 1->31, years 1990->2020")
        elif option == "0":
            data_manager.write_table_to_file(filename, table)
            return False
        else:
            raise KeyError("There is no such option.")
Exemplo n.º 21
0
def handle_menu():
    store_menu = [
        'Show table', 'Add item', 'Remove item', 'Update item',
        'Oldest person', 'People closest to average'
    ]
    ui.print_menu('HR', store_menu, 'Back to main menu')
Exemplo n.º 22
0
def start_module():
    """
    Starts this module and displays its menu.
     * User can access default special features from here.
     * User can go back to main menu from here.

    Returns:
        None
    """
    common.clear()
    special_functions = [
        "Show table", "Add elements", "Remove element by it's ID",
        "Update an element",
        "Get which items have not exceeded their durability yet",
        "Get the average durability times for each manufacturer"
    ]

    table = data_manager.get_table_from_file("inventory/inventory_test.csv")
    ui.print_menu("Inventory Manager MENU", special_functions,
                  "go back to Main Menu.")
    choice = ui.get_inputs(" ", "What's your choice?")
    choice = common.check_one_input_for_number(choice, " ",
                                               "What's your choice?")

    while choice != 0:
        if choice == 1:  #show, choice[0] because from the user inputs we get lists
            show_table(table)

        elif choice == 2:  #add
            add(table)
            data_manager.write_table_to_file("inventory/inventory_test.csv",
                                             table)

        elif choice == 3:  #remove
            id = ui.get_inputs(" ", "Add the searched ID")
            id = id[0]
            remove(table, id)
            data_manager.write_table_to_file("inventory/inventory_test.csv",
                                             table)

        elif choice == 4:  #update
            id = ui.get_inputs(" ", "Add the searched ID")
            id = id[0]
            update(table, id)
            data_manager.write_table_to_file("inventory/inventory_test.csv",
                                             table)

        elif choice == 5:  #exceeded
            year = ui.get_inputs(" ", "Give the year")
            year = common.check_one_input_for_number(year, " ",
                                                     "Give the year")
            ui.print_result(
                get_available_items(table, year),
                "These items that not exceeded their durability yet:")

        elif choice == 6:  #manufactures avg
            result = get_average_durability_by_manufacturers(table)
            ui.print_result(
                result,
                "The average durability times for each manufaturer is:")

        else:
            ui.print_error_message("Wrong input!")

        ui.print_menu("Inventory Manager MENU", special_functions,
                      "go back to Main Menu.")
        choice = ui.get_inputs(" ", "What's your choice?")
        choice = common.check_one_input_for_number(choice, " ",
                                                   "What's your choice?")
        common.clear()

    common.clear()