def run():
    """
    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()
    title = 'Human Resources menu'
    options = ["Add new record to table",
               "Remove a record with a given id from the table.",
               "Updates specified record in the table.",
               "Who is the oldest person?",
               "Who is the closest to the average age?"]
    exit_message = "Back to main menu"

    title_list = ["ID", "NAME", "BIRTH YEAR"]
    table = hr.data_manager.get_table_from_file('model/hr/persons.csv')
    # terminal_view.print_table(table, title_list)

    choice = None
    while choice != "0":
        terminal_view.print_table(table, title_list)
        choice = terminal_view.get_choice(title, options, exit_message)
        if choice == "1":
            record = terminal_view.get_inputs(title_list, 'Please add following informations :', table)
            updated_table = hr.add(table, record)
            hr.data_manager.write_table_to_file('model/hr/persons.csv', updated_table)
            common.exit_prompt()
            common.clear()
        elif choice == "2":
            id_ = terminal_view.get_inputs(['Id'], 'Please give ID to remove :', table)
            updated_table = hr.remove(table, id_)
            hr.data_manager.write_table_to_file('model/hr/persons.csv', updated_table)
            common.exit_prompt()
            common.clear()
        elif choice == "3":
            id_ = terminal_view.get_inputs(['Id'], 'Please give ID of changed line :', table)
            record = terminal_view.get_inputs(title_list, 'Please add following informations :', table)
            updated_table = hr.update(table, id_, record)
            hr.data_manager.write_table_to_file('model/hr/persons.csv', updated_table)
            common.exit_prompt()
            common.clear()
        elif choice == "4":
            result = hr.get_oldest_person(table)
            label = "The oldest person is: "
            terminal_view.print_result(result, label)
            common.exit_prompt()
            common.clear()
        elif choice == "5":
            result = hr.get_persons_closest_to_average(table)
            label = "The closest to the average age is person: ?"
            terminal_view.print_result(result, label)
            common.exit_prompt()
            common.clear()
        elif choice != 0:
            terminal_view.print_error_message("There is no such choice.")
Ejemplo n.º 2
0
def run():
    """
    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
    """
    list_of_customers = crm.get_data_to_list()

    # your code
    options = [
        "Add new record", "Remove a record", "Update record",
        "Id of the customer with the longest name",
        "Customers has subscribed to the newsletter", "Print table"
    ]

    title_list = ["ID", "Name", "e-mail", "subscribed"]

    choice = None
    while choice != "0":
        choice = terminal_view.get_choice(options, "Back to main menu")
        if choice == "1":
            new_record = terminal_view.get_inputs(
                ["Name: ", "e-mail: ", "subscribed: "], "Please enter value: ")
            new_record.insert(0, crm.get_random_id(list_of_customers))
            list_of_customers = crm.add(list_of_customers, new_record)
        elif choice == "2":
            #  id_of_record_to_remove = id_to_number_of_line(list_of_customers)
            id_of_record_to_remove = ask_untill_correct(list_of_customers)
            list_of_customers = crm.remove(
                list_of_customers,
                common.check_id_by_number(list_of_customers,
                                          int(id_of_record_to_remove)))
        elif choice == "3":
            id_of_record_to_update = ask_untill_correct(list_of_customers)
            updated_record = terminal_view.get_inputs(
                ["Name: ", "e-mail: ", "subscribed: "], "Please enter value: ")
            list_of_customers = crm.update(
                list_of_customers,
                common.check_id_by_number(list_of_customers,
                                          int(id_of_record_to_update)),
                updated_record)
        elif choice == "4":
            terminal_view.print_result(
                crm.get_longest_name_id(list_of_customers),
                "Longest person's ID")
        elif choice == "5":
            terminal_view.print_result(
                crm.get_subscribed_emails(list_of_customers),
                "List of subsrcibe user")
        elif choice == "6":
            terminal_view.print_table(list_of_customers, title_list)
        elif choice == "0":
            crm.export_list_to_file(list_of_customers)

        else:
            terminal_view.print_error_message(
                "There is no such choice.")  # your code
Ejemplo n.º 3
0
def run():
    """
    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
    """

    title = "Human resources manager"
    options = [
        "Add item", "Remove item", "Update item", "Show the oldest person",
        "Show person closest to average age"
    ]
    exit_message = "Back to main menu"

    title_list = [['Name'], ['Date of birth']]

    data_file = "model/hr/persons.csv"
    table = data_manager.get_table_from_file(data_file)
    terminal_view.print_table(table, title_list)

    choice = None
    while choice != "0":
        choice = terminal_view.get_choice(title, options, exit_message)
        if choice == "1":
            record = []
            index = 0
            inputs = terminal_view.get_inputs(title_list, title)
            for i in inputs:
                record.insert(index, i)
                index += 1
            hr.add(table, record)
            data_manager.write_table_to_file(data_file, table)
            terminal_view.print_table(table, title_list)

        elif choice == "2":
            user_input = terminal_view.get_inputs(["Enter ID: "], "")
            hr.remove(table, user_input[0])
            terminal_view.print_table(table, title_list)
        elif choice == "3":
            record = []
            index = 0
            user_input = terminal_view.get_inputs(["Enter ID: "], "")
            inputs = terminal_view.get_inputs(title_list, title)
            for i in inputs:
                record.insert(index, i)
                index += 1
            hr.update(table, user_input[0], record)
            terminal_view.print_table(table, title_list)
        elif choice == "4":
            terminal_view.print_result(hr.get_oldest_person(table),
                                       "Oldest person")
        elif choice == "5":
            terminal_view.print_result(
                hr.get_persons_closest_to_average(table),
                "Person closest to average")
        else:
            terminal_view.print_error_message("You have chosen back to menu.")
def run():
    """
    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
    """

    list_options = [
        "1. Add new record to table",
        "2. Remove a record with a given id from the table",
        "3. Update specified record in the table",
        "4. Which items have not exceeded their durability yet?",
        "5. What are the average durability times for each manufacturer?"
    ]

    program_works = True

    while program_works:
        table = inventory.get_table()
        title_list = [
            "ID", "NAME", "MANUFACTURER", "PURCHASE YEAR", "DURABILITY"
        ]
        terminal_view.print_table(table, title_list)

        answer = terminal_view.get_choice(list_options)

        if answer == "1":
            record = terminal_view.get_inputs([
                "ID: ", "Name: ", "Manufacturer: ", "Purchase year: ",
                "Durability: "
            ], "Please provide information: \n")
            common.add(table, record)
            inventory.save_table(table)
        elif answer == "2":
            id_ = terminal_view.get_input("Please enter id number: ")
            common.remove(table, id_)
            inventory.save_table(table)
        elif answer == "3":
            id_ = terminal_view.get_input("Please enter id number: ")
            record = terminal_view.get_inputs([
                "Enter ID: ", "Name of item: ", "Manufacturer: ",
                "Year of purchase", "Durability year"
            ], "Please provide new information")
            common.update(table, id_, record)
            inventory.save_table(table)
        elif answer == "4":
            inventory.get_oldest_person(table)
        elif answer == "5":
            inventory.get_average_durability_by_manufacturers(table)
        elif answer == "0":
            program_works = False
        else:
            terminal_view.print_error_message(
                "There is no such choice. Choose from 1 to 5")
    return
def update(list_labels, list_options, max_id, table, crud_module):
    index_list_options = 4
    title_for_id = list_options[index_list_options]
    title_for_edit = list_options[
        index_list_options] + ' (if you press enter you will not change your data)'
    id_to_edit = terminal_view.get_inputs(['Index to edit', 'id', max_id],
                                          title_for_id)
    inputs = terminal_view.get_inputs(list_labels, title_for_edit)
    write_records(crud_module.update, inputs, table, id_to_edit)
def run():
    """
    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
    """
    list_options = [
        "1. Add new record to table",
        "2. Remove a record with a given id from the table",
        "3. Update specified record in the table",
        "4. Which year has the highest profit?",
        "5. What is the average (per item) profit in a given year?"
    ]

    program_works = True
    while program_works:

        table = accounting.get_table()
        title_list = ["ID", "MONTH", "DAY", "YEAR", "TYPE", "AMOUNT"]
        terminal_view.print_table(table, title_list)

        answer = terminal_view.get_choice(list_options)

        if answer == "1":
            record = terminal_view.get_inputs([
                "ID: ", "Month of the transaction: ",
                "Day of the transaction: ", "Year of the transaction: ",
                "Type - income/outflow (in.out): ",
                "Amount of transaction in USD: "
            ], "Please provide information: \n")
            common.add(table, record)
            accounting.save_table(table)
        elif answer == "2":
            id_ = terminal_view.get_input("Please enter id number: ")
            common.remove(table, id_)
            accounting.save_table(table)
        elif answer == "3":
            id_ = terminal_view.get_input("Please enter id number: ")
            record = terminal_view.get_inputs(
                ["ID: ", "Month: ", "Day: ", "Year: ", "Type: ", "Ammount: "],
                "Please provide new information")
            common.update(table, id_, record)
            accounting.save_table(table)
        elif answer == "4":
            accounting.which_year_max(table)
        elif answer == "5":
            accounting.avg_amount(table, year)
        elif answer == "0":
            program_works = False
        else:
            terminal_view.print_error_message(
                "There is no such choice. Choose from 1 to 5")
    return
def run():
    """
    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
    menu_accounting = [
        "Print accounting list", "Add to accounting list",
        "Remove form accounting list", "Update record in accounting list",
        "Show year with highest profit",
        "Show average profit per item in a given year"
    ]
    title = ["Id", "Month", "Day", "Year", "Type", "Amount"]
    title_del = ["Input ID: "]
    choice = None
    while choice != "0":
        choice = terminal_view.get_choice(menu_accounting)

        if choice == "1":
            terminal_view.print_table(accounting.get_data(), title)

        if choice == "2":
            accounting.new_record(
                common.get_user_inp_record(
                    terminal_view.get_inputs(title[1:], "")),
                "model/accounting/items.csv")

        if choice == "3":
            accounting.delete_record(
                accounting.get_data(),
                common.get_user_inp_record(
                    terminal_view.get_inputs(title_del, "")),
                "model/accounting/items.csv")

        if choice == "4":
            accounting.update_record(
                accounting.get_data(),
                common.get_user_inp_record(
                    terminal_view.get_inputs(title_del, "")),
                terminal_view.get_inputs(title[1:], ""),
                "model/accounting/items.csv")

        if choice == "5":
            terminal_view.print_result(
                accounting.which_year_max(accounting.get_data()),
                "Year with max profit")
        if choice == "6":
            year = terminal_view.get_inputs(["Year:"], "")
            terminal_view.print_result(
                accounting.avg_amount(accounting.get_data(), year[0]),
                "Averange profit per item")
Ejemplo n.º 8
0
def run():
    """
    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

    menu_store = [
        "Print store list", "Add to store list", "Remove form store list",
        "Update record in store list", "Number of games in the manufacture",
        "Average amount of games in stock of a given manufacturer "
    ]
    title = ["ID", "Title", "Manufacturer", "Price", "In_stock"]
    title_del = ["Input ID: "]
    choice = None
    while choice != "0":
        choice = terminal_view.get_choice(menu_store)

        if choice == "1":
            terminal_view.print_table(store.get_data(), title)

        if choice == "2":
            store.new_record(
                common.get_user_inp_record(
                    terminal_view.get_inputs(title[1:], "")),
                "model/store/games.csv")
        if choice == "3":
            store.delete_record(
                store.get_data(),
                common.get_user_inp_record(
                    terminal_view.get_inputs(title_del, "")),
                "model/store/games.csv")
        if choice == "4":
            store.update_record(
                store.get_data(),
                common.get_user_inp_record(
                    terminal_view.get_inputs(title_del, "")),
                terminal_view.get_inputs(title[1:], ""),
                "model/store/games.csv")
        if choice == "5":
            terminal_view.print_result(
                store.get_counts_by_manufacturers(store.get_data()),
                "Different kinds of game are available of each manufacturer: ")
        if choice == "6":
            terminal_view.print_result(
                store.get_average_by_manufacturer(
                    store.get_data(),
                    common.get_user_inp_record(
                        terminal_view.get_inputs(["Input manufactures: "],
                                                 ""))),
                "Average games in manufacturer: ")
def run():
    """
    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
    """

    list_options = [
        "1. Add new record to table",
        "2. Remove a record with a given id from the table",
        "3. Update specified record in the table", "4. Which person is oldest",
        "5. Which person is closest to average"
    ]

    program_works = True

    while program_works:
        table = hr.get_table()
        title_list = ["ID", "NAME", "DATE OF BIRTH"]
        terminal_view.print_table(table, title_list)
        answer = terminal_view.get_choice(list_options)

        if answer == "1":
            record = terminal_view.get_inputs(
                ["ID: ", "Name and surname: ", "Date of birth: "],
                "Please provide your personal information")
            common.add(table, record)
            hr.save_table(table)
        elif answer == "2":
            id_ = terminal_view.get_input("Please enter id number: ")
            common.remove(table, id_)
            hr.save_table(table)
        elif answer == "3":
            id_ = terminal_view.get_input("Please enter id number: ")
            record = terminal_view.get_inputs(
                ["ID: ", "Name and surname: ", "Year of birth: "],
                "Please provide new information")
            common.update(table, id_, record)
            hr.save_table(table)
        elif answer == "4":
            print(hr.get_oldest_person(table))
            # result = hr.get_oldest_person(table)
            # terminal_view.print_result(result, "Oldest person is: ")
        elif answer == "5":
            hr.get_persons_closest_to_average(table)
        elif answer == "0":
            program_works = False
        else:
            terminal_view.print_error_message(
                "There is no such choice. Choose from 1 to 5")
    return
Ejemplo n.º 10
0
def run():
    """
    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

    menu_inventory = [
        "Print inventory list", "Add to inventory list",
        "Remove form inventory list", "Update record in inventory list",
        "Available items", "Average durability"
    ]
    title = ["ID", "Name", "Manufacturer", "Purchase_year", "Durability"]
    title_del = ["Input ID: "]
    choice = None
    while choice != "0":
        choice = terminal_view.get_choice(menu_inventory)

        if choice == "1":
            terminal_view.print_table(inventory.get_data(), title)

        if choice == "2":
            inventory.new_record(
                common.get_user_inp_record(
                    terminal_view.get_inputs(title[1:], "")),
                "model/inventory/inventory.csv")
        if choice == "3":
            inventory.delete_record(
                inventory.get_data(),
                common.get_user_inp_record(
                    terminal_view.get_inputs(title_del, "")),
                "model/inventory/inventory.csv")
        if choice == "4":
            inventory.update_record(
                inventory.get_data(),
                common.get_user_inp_record(
                    terminal_view.get_inputs(title_del, "")),
                terminal_view.get_inputs(title[1:], ""),
                "model/inventory/inventory.csv")
        if choice == "5":
            terminal_view.print_result(
                str(inventory.get_available_items(inventory.get_data())),
                "Available items: ")
        if choice == "6":
            terminal_view.print_result(
                str(
                    inventory.get_average_durability_by_manufacturers(
                        inventory.get_data())), "Oldest persons: ")
Ejemplo n.º 11
0
def run():
    """
    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
    menu_hr = [
        "Print hr list", "Add to hr list", "Remove form hr list",
        "Update record in hr list", "Oldest employe", "Average age"
    ]
    title = ["Id", "Name", "Year"]
    title_del = ["Input ID: "]
    choice = None
    while choice != "0":
        choice = terminal_view.get_choice(menu_hr)

        if choice == "1":
            terminal_view.print_table(hr.get_data(), title)

        if choice == "2":
            hr.new_record(
                common.get_user_inp_record(
                    terminal_view.get_inputs(title[1:], "")),
                "model/hr/persons.csv")

        if choice == "3":
            hr.delete_record(
                hr.get_data(),
                common.get_user_inp_record(
                    terminal_view.get_inputs(title_del, "")),
                "model/hr/persons.csv")

        if choice == "4":
            hr.update_record(
                hr.get_data(),
                common.get_user_inp_record(
                    terminal_view.get_inputs(title_del, "")),
                terminal_view.get_inputs(title[1:], ""),
                "model/hr/persons.csv")

        if choice == "5":
            terminal_view.print_result(
                str(hr.get_oldest_person(hr.get_data())), "Oldest persons: ")
        if choice == "6":
            terminal_view.print_result(
                str(hr.get_persons_closest_to_average(hr.get_data())),
                "Closest to average age: ")
Ejemplo n.º 12
0
def run():
    """
    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 = inventory.get_inventory_table_from_file()
    title_list = ["ID", "NAME", "Manufacturer".upper(), "Year".upper(), "Durability".upper()]
    options = ["View records",
               "Add record",
               "Remove record",
               "Update record",
               "Which items have not exceeded their durability yet?",
               "What are the average durability times for each manufacturer?"]

    choice = None
    while choice != "0":
        choice = terminal_view.get_choice_inner_menu(options, "Inventory manager")
        if choice == "1":
            terminal_view.print_table(table, title_list)
        elif choice == "2":
            data_input_not_correct = True
            while data_input_not_correct:
                record = terminal_view.get_inputs(title_list[1::],"Please provide new item data")
                if record[2].isdigit() and record[3].isdigit():
                    table = inventory.add(table, record)
                    data_input_not_correct = False
                else:
                    terminal_view.print_error_message("Year and durability should be natural numbers!")
        elif choice == "3":
            id_to_delete_table = terminal_view.get_inputs(["ID"],"Item to delete")
            id_to_delete = id_to_delete_table[0]
            table = inventory.remove(table, id_to_delete)
        elif choice == "4":
            records = terminal_view.get_inputs(title_list,"Edit item")
            record_id = records[0]
            table = inventory.update(table, record_id, records)
        elif choice == "5":
            available_items = inventory.get_available_items(table)
            terminal_view.print_table(available_items, title_list)
            #terminal_view.print_result(available_items, "Available items")
        elif choice == "6":
            average_durability = inventory.get_average_durability_by_manufacturers(table)
            list_from_dict = average_durability.items()
            dict_headers = ["MANUFACTURER","DURABILITY"]
            terminal_view.print_table(list_from_dict, dict_headers)
            # terminal_view.print_result(average_durability, "Average durability by manufacturer")
        elif choice != "0":
            terminal_view.print_error_message("There is no such choice.")
Ejemplo n.º 13
0
def run():
    """
    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 = crm.get_crm_table_from_file()
    title_list = ["ID", "Name", "E-mail", "Subscribed"]
    options = [
        "View records", "Add record", "Remove record", "Update record",
        "ID releated with the longest name", "The emails with subscription",
        "The users without subscription"
    ]

    choice = None
    while choice != "0":
        choice = terminal_view.get_choice_inner_menu(
            options, "Customer Relationship Management manager")
        if choice == "1":
            terminal_view.print_table(table, title_list)
        elif choice == "2":
            record = terminal_view.get_inputs(title_list[1::],
                                              "Please provide new item data")
            table = crm.add(table, record)
        elif choice == "3":
            id_to_delete_table = terminal_view.get_inputs(["ID"],
                                                          "Item to delete")
            id_to_delete = id_to_delete_table[0]
            table = crm.remove(table, id_to_delete)
        elif choice == "4":
            records = terminal_view.get_inputs(title_list, "Edit item")
            record_id = records[0]
            table = crm.update(table, record_id, records)
        elif choice == "5":
            longest_name_id = crm.get_longest_name_id(table)
            terminal_view.print_result(longest_name_id,
                                       "The longest name ID: ")
        elif choice == "6":
            subscribed_emails = crm.get_subscribed_emails(table)
            terminal_view.print_result(subscribed_emails,
                                       "The subscribed emails: ")
        elif choice == "7":
            offer = crm.proposition_subscription(table)
            terminal_view.print_result(offer,
                                       "The users without subscription: ")
        elif choice != "0":
            terminal_view.print_error_message("There is no such choice.")
def run():
    """
    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
    """


    list_options = ["1. Add new record to table", 
                    "2. Remove a record with a given id from the table", 
                    "3. Update specified record in the table", 
                    "4. How many different kinds of game are available of each manufacturer?", 
                    "5. What is the average amount of games in stock of a given manufacturer?"]

    
    program_works = True

    while program_works:
        table = store.get_table()
        title_list = ["ID", "TITLE", "MANUFACTURER", "PRICE (in $)", "IN STOCK"]
        terminal_view.print_table(table, title_list)
        
        answer = terminal_view.get_choice(list_options)

        if answer == "1":
            record = terminal_view.get_inputs(["ID: ","Title of the game: ","Manufacturer: ","Price in dollars: ","In stock (number): "],"Please provide information: \n")
            common.add(table, record)
            store.save_table(table)
        elif answer == "2":
            id_ = terminal_view.get_input("Please enter id number: ")
            common.remove(table, id_)
            store.save_table(table)
        elif answer == "3":
            id_ = terminal_view.get_input("Please enter id number: ")
            record = terminal_view.get_inputs(["ID: ","Title of the game: ","Manufacturer: ","Price in dollars: ","In stock (number): "],"Please provide information: \n")
            common.update(table, id_, record)
            store.save_table(table)
        elif answer =="4":
            store.get_counts_by_manufacturers(table)
        elif answer == "5":
            store.get_average_by_manufacturer(table, manufacturer)
        elif answer == "0":
            program_works = False
        else:
            terminal_view.print_error_message("There is no such choice. Choose from 1 to 5")
    return 
Ejemplo n.º 15
0
def run():
    options = ["Display data as a table",
               "Add new data",
               "Remove data",
               "Update",
               "Get amount of games by each manufactor",
               "Get amount of games by manufacture"]
    table_titles = ["id", "title", "manufacturer", "price", "in_stock"]
    choice = None
    while choice != "0":
        terminal_view.print_menu("Store manager menu ", options, "Go back to main menu")
        inputs = terminal_view.get_inputs(["Please enter a number: "], "")
        choice = inputs[0]
        #reading data from file
        data_table = data_manager.get_table_from_file("model/store/games.csv")
        if choice == "1":
            terminal_view.print_table(data_table, table_titles)
        elif choice == "2":
            table_titles.pop(0)
            store.add(data_table, table_titles)
        elif choice == "3":
            store.remove(data_table, get_user_id("remove"))
        elif choice == "4":
            store.update(data_table, get_user_id("update"), common.get_user_record(table_titles[1:]))
        elif choice == "5":
            sales_controller.run()
        elif choice == "6":
            crm_controller.run()
        elif choice == "0":
            root_controller.run()
        else:
            terminal_view.print_error_message("There is no such choice.")
Ejemplo n.º 16
0
def generate_record(table, columns_headers, ask_information, filename):
    table = common.get_table_from_file(filename)
    id = common.generate_random(table)
    record = terminal_view.get_inputs(columns_headers, ask_information)

    record.insert(0, id)
    return record
def run():
    options = ["Display data as a table",
               "Add new data",
               "Remove data",
               "Update",
               "Which year has the highest profit?",
               "What is the average (per item) profit in a given year?"]
    table_titles = ["id", "month of the transaction", "day of the transaction", "year", "type", "amount"]
    choice = None
    while choice != "0":
        terminal_view.print_menu("Accounting menu ", options, "Go back to main menu")
        inputs = terminal_view.get_inputs(["Please enter a number: "], "")
        choice = inputs[0]
        #reading data from file
        data_table = data_manager.get_table_from_file("model/accounting/items.csv")
        if choice == "1":
            terminal_view.print_table(data_table, table_titles)
        elif choice == "2":
            table_titles.pop(0)
            accounting.add(data_table, table_titles)
        elif choice == "3":
            accounting.remove(data_table, get_user_id("remove"))
        elif choice == "4":
            accounting.update(data_table, get_user_id("update"), common.get_user_record(table_titles[1:]))
        elif choice == "5":
            sales_controller.run()
        elif choice == "6":
            crm_controller.run()
        elif choice == "0":
            root_controller.run()
        else:
            terminal_view.print_error_message("There is no such choice.")
Ejemplo n.º 18
0
def run():
    options = [
        "Display data as a table", "Add new data", "Remove data", "Update",
        "What is the id of the item that was sold for the lowest price?",
        "Which items are sold between two given dates?"
    ]
    choice = None
    while choice != "0":
        terminal_view.print_menu("Sales menu ", options,
                                 "Go back to main menu")
        inputs = terminal_view.get_inputs(["Please enter a number: "], "")
        choice = inputs[0]
        table_titles = ["id", "title", "price", "month", "day", "year"]
        #reading data from file
        data_table = data_manager.get_table_from_file("model/sales/sales.csv")
        if choice == "1":
            terminal_view.print_table(data_table, table_titles)
        elif choice == "2":
            table_titles.pop(0)
            sales.add(data_table, table_titles)
        elif choice == "3":
            sales.remove(data_table, get_user_id("remove"))
        elif choice == "4":
            sales.update(data_table, get_user_id("update"),
                         common.get_user_record(table_titles[1:]))
        elif choice == "5":
            sales_controller.run()
        elif choice == "6":
            crm_controller.run()
        elif choice == "0":
            root_controller.run()
        else:
            terminal_view.print_error_message("There is no such choice.")
def update(file, common_options):
    get_table_from(file)
    id_ = terminal_view.get_input("ID: ",
                                  "Please provide ID, which you want to edit")
    record = terminal_view.get_inputs([opt for opt in common_options],
                                      "Please provide following data: ")
    save(file, common.update(get_table_from(file), id_, record))
def run():
    options = [
        "Display data as a table", "Add new data", "Remove data", "Update",
        "What is the id of the customer with the longest name?",
        "Which customers has subscribed to the newsletter?"
    ]
    choice = None
    while choice != "0":
        terminal_view.print_menu("CRM menu ", options, "Go back to main menu")
        inputs = terminal_view.get_inputs(["Please enter a number: "], "")
        choice = inputs[0]
        table_titles = ["id", "name", "email", "subscribed"]
        #reading data from file
        data_table = data_manager.get_table_from_file(
            "model/crm/customers.csv")
        if choice == "1":
            terminal_view.print_table(data_table, table_titles)
        elif choice == "2":
            table_titles.pop(0)
            crm.add(data_table, table_titles)
        elif choice == "3":
            crm.remove(data_table, get_user_id("remove"))
        elif choice == "4":
            crm.update(data_table, get_user_id("update"),
                       common.get_user_record(table_titles[1:]))
        elif choice == "5":
            sales_controller.run()
        elif choice == "6":
            crm_controller.run()
        elif choice == "0":
            root_controller.run()
        else:
            terminal_view.print_error_message("There is no such choice.")
Ejemplo n.º 21
0
def ask_untill_correct(list_of_inventory):
    is_correct = False
    FIRST_ELEMENT_IN_LIST = 0
    while is_correct is not True:
        id_of_record = terminal_view.get_inputs(["Line number: "], "Please enter value ")
        is_correct = common.check_is_number(id_of_record[FIRST_ELEMENT_IN_LIST], len(list_of_inventory))
    return id_of_record[FIRST_ELEMENT_IN_LIST]
Ejemplo n.º 22
0
def run():
    options = [
        "Add", "Remove", "Update", "Count by manufacturer",
        "Average games in stock by manufacturer"
    ]
    common_options = ["Title: ", "Manufacturer: ", "Price: ", "In stock: "]
    file = "model/store/games.csv"
    title_list = ["Id", "Title", "Manufacturer", "Price", "In stock"]
    choice = None
    terminal_clear = True
    while choice != '0':
        if terminal_clear:
            table = common.clear_instructions(file, title_list)
        choice = terminal_view.get_choice_submenu(options)
        terminal_clear = True
        if choice == '1':
            common.add(file, common_options)
        elif choice == '2':
            common.remove(file)
        elif choice == '3':
            common.update(file, common_options)
        elif choice == '4':
            msg = "Products by manufacturer:\n"
            terminal_view.print_result(
                store.get_counts_by_manufacturers(table), msg)
            terminal_clear = False
        elif choice == '5':
            manufacturer = terminal_view.get_inputs(
                ["Manufacturer: "], "Please provide manufacturer name")
            msg = "Average by " + manufacturer[0] + ":"
            value = store.get_average_by_manufacturer(table, manufacturer[0])
            terminal_view.print_result(value, msg)
            terminal_clear = False
        else:
            terminal_view.print_error_message("There is no such choice.")
def run():
    options = [
        "Display data as a table", "Add new data", "Remove data", "Update",
        "Who is the oldest person?", "Who is the closest to the average age?"
    ]
    choice = None
    while choice != "0":
        terminal_view.print_menu("Human resources menu ", options,
                                 "Go back to main menu")
        inputs = terminal_view.get_inputs(["Please enter a number: "], "")
        choice = inputs[0]
        table_titles = ["id", "name", "year of birth"]
        #reading data from file
        data_table = data_manager.get_table_from_file("model/hr/persons.csv")
        if choice == "1":
            terminal_view.print_table(data_table, table_titles)
        elif choice == "2":
            table_titles.pop(0)
            hr.add(data_table, table_titles)
        elif choice == "3":
            hr.remove(data_table, get_user_id("remove"))
        elif choice == "4":
            hr.update(data_table, get_user_id("update"),
                      common.get_user_record(table_titles[1:]))
        elif choice == "5":
            sales_controller.run()
        elif choice == "6":
            crm_controller.run()
        elif choice == "0":
            root_controller.run()
        else:
            terminal_view.print_error_message("There is no such choice.")
Ejemplo n.º 24
0
def run():
    """
    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
    """
    menu_controller = [
        "Print controller list", "Add to controller list",
        "Remove form controller list", "Update record in controller list",
        "Show subscribers", "Show longest name ID"
    ]
    title = ["ID", "Name", "E-mail", "Subscribed"]
    title_del = ["Input ID: "]
    choice = None
    while choice != "0":
        choice = terminal_view.get_choice(menu_controller)

        if choice == "1":
            terminal_view.print_table(crm.get_data(), title)

        if choice == "2":
            crm.new_record(
                common.get_user_inp_record(
                    terminal_view.get_inputs(title[1:], "")),
                "model/crm/customers.csv")
        if choice == "3":
            crm.delete_record(
                crm.get_data(),
                common.get_user_inp_record(
                    terminal_view.get_inputs(title_del, "")),
                "model/crm/customers.csv")
        if choice == "4":
            crm.update_record(
                crm.get_data(),
                common.get_user_inp_record(
                    terminal_view.get_inputs(title_del, "")),
                terminal_view.get_inputs(title[1:], ""),
                "model/crm/customers.csv")
        if choice == "5":
            terminal_view.print_result(
                crm.get_subscribed_emails(crm.get_data()), "Subscribers")
        if choice == "6":
            terminal_view.print_result(crm.get_longest_name_id(crm.get_data()),
                                       "Longest name ID")
def run():
    """
    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
    """

    list_options = ["1. Add new record to table", 
                    "2. Remove a record with a given id from the table", 
                    "3. Update specified record in the table", 
                    "4. What is the id of the item that was sold for the lowest price?", 
                    "5. Which items are sold between two given dates?"]
    
    program_works = True

    while program_works:
        table = sales.get_table()  
        title_list = ["ID", "TITLE", "PRICE","MONTH","DAY","YEAR"]
        terminal_view.print_table(table, title_list)

        answer = terminal_view.get_choice(list_options)

        if answer == "1":
            record = terminal_view.get_inputs(["ID: ","Title of the game sold: ","The actual sale price in USD: ","Month of the sale: ","Day of the sale: ","Year of the sale: "],"Please provide information: \n")
            common.add(table, record)
            sales.save_table(table)
        elif answer == "2":
            id_ = terminal_view.get_input("Please enter id number: ")
            common.remove(table, id_)
            sales.save_table(table)
        elif answer == "3":
            id_ = terminal_view.get_input("Please enter id number: ")
            record = terminal_view.get_inputs(["ID: ","Title of the game sold: ","The actual sale price in USD: ","Month of the sale: ","Day of the sale: ","Year of the sale: "],"Please provide information: \n")
            common.update(table, id_, record)
            sales.save_table(table)
        elif answer == "4":
            sales.get_oldest_person(table)
        elif answer == "5":
            sales.get_items_sold_between(table, month_from, day_from, year_from, month_to, day_to, year_to)
        elif answer == "0":
            program_works = False
        else:
            terminal_view.print_error_message("There is no such choice. Choose from 1 to 5")
    return 
Ejemplo n.º 26
0
def run():
    """
    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
    """
    list_of_inventory = inventory.get_data_to_list()

    # your code
    options = ["Add new record",
               "Remove a record",
               "Update record",
               "Display available items",
               "Get average durability by manufacturers",
               "Print Table"]

    title_list = ["ID", "CONSOLA", "PRODUCENT", "YEAR", "DURABILITY"]

    choice = None
    while choice != "0":
        choice = terminal_view.get_choice(options, "Back to main menu")
        if choice == "1":
            new_record = terminal_view.get_inputs(["Name: ", "Manufacturer: ", "Purchase year: ", "Durability: "], "Please enter value: ")
            new_record.insert(0, inventory.get_random_id(list_of_inventory))
            list_of_inventory = inventory.add(list_of_inventory, new_record)
        elif choice == "2":
            id_of_record_to_remove = ask_untill_correct(list_of_inventory)
            list_of_inventory = inventory.remove(list_of_inventory, common.check_id_by_number(list_of_inventory, int(id_of_record_to_remove)))
        elif choice == "3":
            id_of_record_to_update = ask_untill_correct(list_of_inventory)
            updated_record = terminal_view.get_inputs(["Name: ", "Manufacturer: ", "Purchase year: ", "Durability: "], "Please enter value: ")
            list_of_inventory = inventory.update(list_of_inventory, common.check_id_by_number(list_of_inventory, int(id_of_record_to_update)), updated_record)
        elif choice == "4":
            available_items = inventory.get_available_items(list_of_inventory)
            terminal_view.print_result(available_items, "Available items")
        elif choice == "5":
            average_durability = inventory.get_average_durability_by_manufacturers(list_of_inventory)
            terminal_view.print_result(average_durability, "Average durability by manufacturers")
        elif choice == "6":
            terminal_view.print_table(list_of_inventory, title_list)
        elif choice == "0":
            inventory.export_list_to_file(list_of_inventory)
        else:
            terminal_view.print_error_message("There is no such choice.")
Ejemplo n.º 27
0
def get_user_record(labels):
    user_inputs = []
    record = []
    for label in labels:
        user_inputs.append(get_inputs([f"{label}: "], ""))
    for user_input in user_inputs:
        record.append(user_input[0])
    return record
def run():
    """
    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_headers = ['ID', 'Title', 'Price', 'Month', 'Day', 'Year']
    choice = None
    filename = 'model/sales/sales.csv'
    columns_headers = ['Title', 'Price', 'Month', 'Day', 'Year']
    ask_information = "Please provide your personal information"

    common.print_art(0)
    while choice != "0":
        choice = terminal_view.get_submenu_choice([
            'Add', 'Remove', 'Update', 'Check lowest price item',
            'Check items sold between dates'
        ])
        table = common.get_table_from_file(filename)

        if choice[0] == "1":
            common.clear_terminal()
            common.adding(table, table_headers, filename, columns_headers,
                          ask_information)
        elif choice[0] == "2":
            common.clear_terminal()
            common.removing(table, table_headers, id, filename)
        elif choice == "3":
            common.clear_terminal()
            common.updating(table, table_headers, id, filename,
                            columns_headers, ask_information)
        elif choice == "4":
            common.clear_terminal()
            terminal_view.print_table(table, table_headers)
            sales_id = sales.get_lowest_price_item_id(table)
            terminal_view.print_result("The lowest price item id is", sales_id)
        elif choice == "5":
            common.clear_terminal()
            terminal_view.print_table(table, table_headers)
            date_list = terminal_view.get_inputs([
                'month_from', 'day_from', 'year_from', 'month_to', 'day_to',
                'year_to'
            ], "Please provide dates information: ")
            sold_list = sales.get_items_sold_between(table, int(date_list[0]),
                                                     int(date_list[1]),
                                                     int(date_list[2]),
                                                     int(date_list[3]),
                                                     int(date_list[4]),
                                                     int(date_list[5]))
            terminal_view.print_result(
                "The items sold between given dates are:", sold_list)
        elif int(choice) >= 6:
            common.clear_terminal()
            terminal_view.print_error_message("There is no such choice.")
Ejemplo n.º 29
0
def run():
	"""
	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
	"""
	
	list_options = [
		'Sales',
		'Show all data',
		'Add',
		'Remove',
		'Update',
		'Get lowest price item id',
		'Get items sold between',
		'Exit to main menu'
	]
	data_file = "model/sales/sales.csv"
	crud_module = sales
	while True:
		table = data_manager.get_table_from_file(data_file)
		max_id = len(table)
		list_labels = [
			['Title', str],
			['Price', int],
			['Month', 'month'],
			['Day', 'day'],
			['Year', 'year'],
			['Customer', str]
		]
		user_choice = terminal_view.get_choice(list_options)
		if user_choice in ['1', '2', '3', '4']:
			make_crud(crud_module, list_labels, list_options, max_id, table, user_choice)
		elif user_choice == '5':
			result = sales.get_lowest_price_item_id(table)
			terminal_view.print_result(result, "Lowest price item ID")
		elif user_choice == '6':
			inputs_labels_between = [
				['Date from', 'date'],
				['Date to', 'date'],
			]
			inputs = terminal_view.get_inputs(['must'] + inputs_labels_between, 'Date from to')
			inputs = [int(item) for item in inputs]
			result = sales.get_items_sold_between(table, *inputs)
			print(common.bcolors.WARNING + common.bcolors.BOLD)
			terminal_view.os.system('clear')
			if common.check_if_empty(result):
				terminal_view.print_table(result, list_labels)
			print(common.bcolors.ENDC)
		
		elif user_choice == '0':
			break
		
		else:
			terminal_view.print_error_message("There is no such choice.")
Ejemplo n.º 30
0
def ask_untill_correct(list_label, end_range):
    is_correct = False
    FIRST_ELEMENT_IN_LIST = 0
    while is_correct is not True:
        id_of_record = terminal_view.get_inputs(list_label,
                                                "Please enter value ")
        is_correct = common.check_is_number(
            id_of_record[FIRST_ELEMENT_IN_LIST], end_range)
    return int(id_of_record[FIRST_ELEMENT_IN_LIST])