Exemplo n.º 1
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_list = ["* id", "* name", "* email", "* subscribed"]

    options = [
        "Add new record to table",
        "Remove a record with a given id from the table",
        "Update specified record in the table",
        "ID of the customer with the longest name",
        "Customers that have subscribed to the newsletter", "Print table"
    ]
    os.system('clear')
    file = "model/crm/customers.csv"
    choice = None
    while choice != "0":
        terminal_view.print_menu("What do you want to do:", options,
                                 "Back to main menu")
        choice = terminal_view.get_choice(options)
        if choice == "1":
            common.all_add(title_list, file)
        elif choice == "2":
            common.all_remove(title_list, file)
        elif choice == "3":
            common.all_updates(title_list, file)
        elif choice == "4":
            file_name = common.get_input("Choose a file: ")
            if file_name == "":
                file_name = file
            table = common.get_table_from_file(file_name)
            id_with_longest_name = crm.get_longest_name_id(table)
            os.system("clear")
            print("ID of the customer with the longest name: ",
                  id_with_longest_name)
            common.waiting()
            os.system("clear")
        elif choice == "5":
            file_name = common.get_input("Choose a file: ")
            if file_name == "":
                file_name = file
            table = common.get_table_from_file(file_name)
            subscribed_mails = crm.get_subscribed_emails(table)
            os.system("clear")
            print("Customers that have subscribed to the newsletter: ",
                  subscribed_mails)
            common.waiting()
            os.system("clear")
        elif choice == "6":
            common.all_print_table(title_list, file)

        else:
            if choice != "0":
                terminal_view.print_error_message("There is no such choice.")
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.")
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.")
def run():
    options = [
        "Store manager", "Human resources manager", "Inventory manager",
        "Accounting manager", "Sales manager",
        "Customer Relationship Management (CRM)", "Data analyser"
    ]

    choice = None
    while choice != "0":
        common.clear_function()
        terminal_view.print_primitive_logo()
        terminal_view.print_menu("Main menu: ", options, "Exit program")
        choice = terminal_view.get_choice()
        common.clear_function()
        if choice == "1":
            store_controller.run()
        elif choice == "2":
            hr_controller.run()
        elif choice == "3":
            inventory_controller.run()
        elif choice == "4":
            accounting_controller.run()
        elif choice == "5":
            sales_controller.run()
        elif choice == "6":
            crm_controller.run()
        elif choice == "7":
            data_analyser_controller.run()
        else:
            pass
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.")
def run():
    options = ["Store manager",
               "Human resources manager",
               "Inventory manager",
               "Accounting manager",
               "Sales manager",
               "Customer Relationship Management (CRM)"]

    choice = None
    while choice != "0":
        terminal_view.print_menu("Main menu:",options, "Exit program")
        choice = terminal_view.get_choice(options)
        if choice == "1":
            store_controller.run()
        elif choice == "2":
            hr_controller.run()
        elif choice == "3":
            inventory_controller.run()
        elif choice == "4":
            accounting_controller.run()
        elif choice == "5":
            sales_controller.run()
        elif choice == "6":
            crm_controller.run()
        else:
            terminal_view.print_error_message("There is no such choice.")
Exemplo n.º 7
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.")
Exemplo n.º 8
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.")
def run():
    options = [
        "Store manager", "Human resources manager", "Inventory manager",
        "Accounting manager", "Sales manager",
        "Customer Relationship Management (CRM)", "Data Analyzer"
    ]

    os.system("clear")
    choice = None
    while choice != "0":
        os.system("clear")
        terminal_view.print_predator()
        terminal_view.print_menu("What controller would you like to open:",
                                 options, "Exit")
        choice = terminal_view.get_choice(options)
        os.system("clear")
        if choice == "1":
            store_controller.run()
        elif choice == "2":
            hr_controller.run()
        elif choice == "3":
            inventory_controller.run()
        elif choice == "4":
            accounting_controller.run()
        elif choice == "5":
            sales_controller.run()
        elif choice == "6":
            crm_controller.run()
        elif choice == "7":
            data_analysis_controller.run()
        else:
            if choice != "0":
                terminal_view.print_error_message("There is no such choice.\n")
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_list = [
        "* ID", "* Month of the transaction", "* Day of the transaction",
        "* Year of the transaction", "* Type", "* Amount in USD"
    ]

    options = [
        "Add new record to table",
        "Remove a record with a given id from the table",
        "Update specified record in the table", "Year of the highest profit",
        "Average profit in a given year", "Print table"
    ]
    os.system('clear')
    file = "model/accounting/items.csv"
    choice = None
    while choice != "0":
        terminal_view.print_menu("What do you want to do:", options,
                                 "Back to main menu")
        choice = terminal_view.get_choice(options)
        if choice == "1":
            common.all_add(title_list, file)
        elif choice == "2":
            common.all_remove(title_list, file)
        elif choice == "3":
            common.all_updates(title_list, file)
        elif choice == "4":
            file_name = common.get_input("Choose a file: ")
            if file_name == "":
                file_name = file
            table = common.get_table_from_file(file_name)
            year_of_highest_profit = accounting.which_year_max(table)
            os.system("clear")
            print("Year of the highest profit:", year_of_highest_profit)
            common.waiting()
            os.system("clear")
        elif choice == "5":
            file_name = common.get_input("Choose a file: ")
            if file_name == "":
                file_name = file
            table = common.get_table_from_file(file_name)
            terminal_view.print_table(table, title_list)
            year = int(common.get_input("Enter year: "))
            print(accounting.avg_amount(table, year))
            common.waiting()
            os.system("clear")
        elif choice == "6":
            common.all_print_table(title_list, file)
        else:
            if choice != "0":
                terminal_view.print_error_message("There is no such choice.")
Exemplo n.º 11
0
def run():
    """
Uruchamia ten moduł i wyświetla jego menu.
     * Użytkownik ma tutaj dostęp do domyślnych funkcji specjalnych.
     * Użytkownik może wrócić do głównego menu.

    Zwroty:
        Żaden
    """

    options = [
        "Add new record to table", "Remove a record", "Update a record",
        "Get oldest person in file",
        "Get closest person to average year in file", "Print table"
    ]

    title_list = ["*id", "person", "year"]
    os.system('clear')
    file = "model/hr/persons.csv"
    choice = None
    while choice != "0":
        terminal_view.print_menu("What do you want to do: ", options,
                                 "Back to main menu")
        choice = terminal_view.get_choice(options)
        if choice == "1":
            common.all_add(title_list, file)
        elif choice == "2":
            common.all_remove(title_list, file)
        elif choice == "3":
            common.all_updates(title_list, file)
        elif choice == "4":
            file_name = common.get_input("Choose a file: ")
            if file_name == "":
                file_name = file
            table = common.get_table_from_file(file_name)
            oldest_person = hr.get_oldest_person(table)
            os.system("clear")
            print("The oldest persons in the file: ", oldest_person)
            common.waiting()
            os.system("clear")
        elif choice == "5":
            file_name = common.get_input("Choose a file: ")
            if file_name == "":
                file_name = file
            table = common.get_table_from_file(file_name)
            closest_to_average = hr.get_persons_closest_to_average(table)
            os.system("clear")
            print("Closest person to average year is:", closest_to_average)
            common.waiting()
            os.system("clear")
        elif choice == "6":
            common.all_print_table(title_list, file)

        else:
            if 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
    """

    title_list = ["* id",
                  "* title",
                  "* price",
                  "* month of the sale",
                  "* day of the sale",
                  "* year of the sale",
                  "* id of customer"]

    options = ["Add new record to table",
               "Remove a record with a given id from the table",
               "Update specified record in the table",
               "ID of the item that was sold for the lowest price",
               "Items that are sold between two given dates",
               "Print table"]
    os.system('clear')
    file = "model/sales/sales.csv"
    choice = None
    while choice != "0":
        terminal_view.print_menu("What do you want to do:", options, "Back to main menu")
        choice = terminal_view.get_choice(options)
        if choice == "1":
            common.all_add(title_list, file)
        elif choice == "2":
            common.all_remove(title_list, file)
        elif choice == "3":
            common.all_updates(title_list, file)
        elif choice == "4":
            file_name = common.get_input("Choose a file: ")
            if file_name == "":
                file_name = file
            table = common.get_table_from_file(file_name)
            item_the_lowest_price = sales.get_lowest_price_item_id(table)
            os.system("clear")
            print("id of the item that was sold for the lowest price: ", item_the_lowest_price)
            common.waiting()
            os.system("clear")
        elif choice == "5":
            pass
        elif choice == "6":
            common.all_print_table(title_list, file)

        else:
            if 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
    """
    options = [
        "Add new record", "Remove record", "Update record",
        "Which year has the highest profit?",
        "What is the average (per item) profit in a given year?"
    ]

    terminal_view.print_menu("Menu", options, "Back to Main 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
    """

    options = [
        "Add new record", "Remove record", "Update record",
        "What is the id of the customer with the longest name?",
        "Which customers has subscribed to the newsletter?"
    ]
    data = common.get_table(
        "/home/stanki/Desktop/ERP_TW/erp-mvc-marcin_marcin_natalia/model/crm/customers.csv"
    )
    print(data)
    title_list = ["id", "Name", "Email", "Subscribed"]
    common.draw_table(data, title_list)
    terminal_view.print_menu("Menu", options, "Back to Main Menu")
    choice = terminal_view.get_choice(options)

    while choice != "0":
        if choice == "1":
            store_controller.run()
        elif choice == "2":
            hr_controller.run()
        elif choice == "3":
            inventory_controller.run()
        elif choice == "4":
            accounting_controller.run()
        elif choice == "5":
            sales_controller.run()
        elif choice == "6":
            crm_controller.run()
        else:
            terminal_view.print_error_message("There is no such choice.")
Exemplo n.º 15
0
def run():
    options = [
        "Display data as a table", "Add new data", "Remove data", "Update",
        "Which items have not exceeded their durability yet?",
        "What are the average durability times for each manufacturer?"
    ]
    choice = None
    while choice != "0":
        terminal_view.print_menu("Inventory menu ", options,
                                 "Go back to main menu")
        inputs = terminal_view.get_inputs(["Please enter a number: "], "")
        choice = inputs[0]
        table_titles = [
            "id", "name", "manufacturer", "Year of purchase", "durability"
        ]
        #reading data from file
        data_table = data_manager.get_table_from_file(
            "model/inventory/inventory.csv")
        if choice == "1":
            terminal_view.print_table(data_table, table_titles)
        elif choice == "2":
            table_titles.pop(0)
            inventory.add(data_table, table_titles)
        elif choice == "3":
            inventory.remove(data_table, get_user_id("remove"))
        elif choice == "4":
            inventory.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.")
Exemplo n.º 16
0
def common_controlls(options,
                     title_list,
                     file_name,
                     controll_name,
                     get_record_data,
                     crm_or_extended_sales=None):
    table = data_manager.get_table_from_file(file_name)
    terminal_view.print_primitive_logo()
    terminal_view.print_menu("Choose option:", options, "Back to main menu")
    choice = None
    while choice != "0":
        choice = terminal_view.get_choice().upper()
        table = data_manager.get_table_from_file(file_name)
        clear_function()
        if choice == "1":
            data_manager.write_table_to_file(
                file_name,
                controll_name.add(table,
                                  terminal_view.get_record(get_record_data)))
            terminal_view.print_primitive_logo()
            table = data_manager.get_table_from_file(file_name)
            terminal_view.print_menu("Choose option:", options,
                                     "Back to main menu")
        elif choice == "2":
            terminal_view.print_primitive_logo()
            terminal_view.print_table(table, title_list)
            terminal_view.print_menu("Choose option:", options,
                                     "Back to main menu")
        elif choice == "3":
            terminal_view.print_primitive_logo()
            terminal_view.print_table(table, title_list)
            data_manager.write_table_to_file(
                file_name,
                controll_name.update(
                    table, terminal_view.get_id(),
                    terminal_view.get_record(get_record_data)))
            table = data_manager.get_table_from_file(file_name)
            terminal_view.print_menu("Choose option:", options,
                                     "Back to main menu")
        elif choice == "4":
            terminal_view.print_primitive_logo()
            terminal_view.print_table(table, title_list)
            data_manager.write_table_to_file(
                file_name, controll_name.remove(table, terminal_view.get_id()))
            table = data_manager.get_table_from_file(file_name)
            terminal_view.print_menu("Choose option:", options,
                                     "Back to main menu")
        elif choice == "5":
            terminal_view.print_primitive_logo()
            terminal_view.print_result(controll_name.special_function(table))
            terminal_view.print_menu("Choose option:", options,
                                     "Back to main menu")
        elif choice == "6":
            terminal_view.print_primitive_logo()
            terminal_view.print_result(controll_name.special_function2(table))
            terminal_view.print_menu("Choose option:", options,
                                     "Back to main menu")
        else:
            if crm_or_extended_sales:
                extended_sales(choice, controll_name)
                terminal_view.print_menu("Choose option:", options,
                                         "Back to main menu")
            elif not crm_or_extended_sales:
                extended_crm(choice, table, controll_name, title_list)
                terminal_view.print_menu("Choose option:", options,
                                         "Back to main menu")
            else:
                terminal_view.print_primitive_logo()
                terminal_view.print_error_message("There is no such choice.")
                terminal_view.print_menu("Choose option:", options,
                                         "Back to main menu")
Exemplo n.º 17
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
    """

    options = [
        "Add new record to table",
        "Remove a record with a given id from the table",
        "Update specified record in the table",
        "Number of different kinds of game that are available of each manufacturer",
        "Average amount of games in stock of a given manufacturer",
        "Print table"
    ]

    title_list = ["*id", "* title", "* manufacturer", "* price", "* in_stock"]
    os.system('clear')
    choice = None
    while choice != "0":
        terminal_view.print_menu("What do you want to do:", options,
                                 "Back to main menu")
        choice = terminal_view.get_choice(options)
        os.system('clear')
        if choice == "1":
            # to jest dzialajacy plik               model/store/games.csv
            file_name = common.get_input("Choose a file: ")
            if file_name == "":
                file_name = "model/store/games.csv"
            table = common.get_table_from_file(file_name)
            terminal_view.print_table(table, title_list)
            record = terminal_view.get_inputs(title_list, "Enter data: ")
            table = store.add(table, record)
            common.write_table_to_file(file_name, table)
            os.system("clear")
            terminal_view.gprint('*** Record has been added ***')
            common.waiting()
            os.system("clear")
        elif choice == "2":
            file_name = common.get_input("Choose a file: ")
            if file_name == "":
                file_name = "model/store/games.csv"
            table = common.get_table_from_file(file_name)
            terminal_view.print_table(table, title_list)
            id_ = common.get_input("Get id to removed: ")
            table = store.remove(table, id_)
            common.write_table_to_file(file_name, table)
            os.system("clear")
            terminal_view.gprint('*** Record has been removed ***')
            common.waiting()
            os.system("clear")
        elif choice == "3":
            file_name = common.get_input("Choose a file: ")
            if file_name == "":
                file_name = "model/store/games.csv"
            table = common.get_table_from_file(file_name)
            terminal_view.print_table(table, title_list)
            id_ = common.get_input("Enter id to update: ")
            record = terminal_view.get_inputs(title_list, "Enter data: ")
            table = store.update(table, id_, record)
            common.write_table_to_file(file_name, table)
            os.system("clear")
            terminal_view.gprint('*** Record has been updated ***')
            common.waiting()
            os.system("clear")
        elif choice == "4":
            file_name = common.get_input("Choose a file: ")
            if file_name == "":
                file_name = "model/store/games.csv"
            table = common.get_table_from_file(file_name)
            dictionary = store.get_counts_by_manufacturers(table)
            terminal_view.print_dictionary(
                "Number of different kinds of game that are" +
                "available of each manufacturer:", dictionary)
            common.waiting()
            os.system("clear")
        elif choice == "5":
            file_name = common.get_input("Choose a file: ")
            if file_name == "":
                file_name = "model/store/games.csv"
            table = common.get_table_from_file(file_name)
            terminal_view.print_table(table, title_list)
            manufacturer = common.get_input("Enter a manufacturer: ")
            print(store.get_average_by_manufacturer(table, manufacturer))
            common.waiting()
            os.system("clear")
        elif choice == "6":
            file_name = common.get_input("Choose a file: ")
            if file_name == "":
                file_name = "model/store/games.csv"
            table = common.get_table_from_file(file_name)
            terminal_view.print_table(table, title_list)
            common.waiting()
            os.system("clear")

        else:
            if choice != "0":
                terminal_view.print_error_message("There is no such choice.")
Exemplo n.º 18
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_list = [
        "* id of item", "* title", "* price", "* month of the sale",
        "* day of the sale", "* year of the sale", "* customer's id"
    ]

    # ! sign with a position is unfinished function but added in options
    # !8. Show the sale numbers of games for each customer-292
    # !11. Show the customer who spent the most and the amount spent-365"
    # !12. Show the customer's id who spent the most and the amount spent-376"
    # !13. Show the most frequent buyers-387
    # !14. Show the if of the most freuent buyers-

    options = [
        "Print table", "Get game title by id",
        "Show the most recently sold game",
        "Get the sum of games' prices by their id",
        "Get the customer's id by the id of a game",
        "Show ids of all customers who purchased games",
        "Show sale ids of all customers",
        "Show the owner of a recently sold game",
        "Show the owner's id of a recently sold game",
        "Show the most frequent buyers",
        "Show the ids of the most frequent buyers", "Get the customer by id"
    ]

    os.system('clear')
    file = "model/sales/sales.csv"
    choice = None
    while choice != "0":
        os.system('clear')
        terminal_view.print_predator()
        terminal_view.print_menu("What do you want to do:", options,
                                 "Back to main menu")
        choice = terminal_view.get_choice(options)

        if choice == "1":
            os.system("clear")
            common.all_print_table(title_list, file)

        elif choice == "2":
            os.system("clear")
            print("Get game title by id\n")
            file_name = common.get_file()
            if file_name == "":
                file_name = file
            table = common.get_table_from_file(file_name)
            terminal_view.print_table(table, title_list)
            identification = common.get_input("Enter the id: ")
            print(sales.get_title_by_id_from_table(table, identification))
            common.waiting()
            os.system("clear")

        elif choice == "3":
            file_name = common.get_file()
            if file_name == "":
                file_name = file
            table = common.get_table_from_file(file_name)
            most_recently_sold_game = sales.get_item_id_title_sold_last(table)
            print("The most recently sold game is: ")
            terminal_view.print_table([most_recently_sold_game],
                                      ["* id", "* title"])
            common.waiting()
            os.system("clear")

        elif choice == "4":
            os.system("clear")
            print("Get the sum of games' prices by their id\n")
            file_name = common.get_file()
            if file_name == "":
                file_name = file
            table = common.get_table_from_file(file_name)
            terminal_view.print_table(table, title_list)
            item_ids = []
            x = True
            while x:
                add_id = common.get_input("Enter the id or 'x' to exit: ")
                if add_id == "x":
                    x = False
                item_ids.append(add_id)
            print(sales.get_the_sum_of_prices_from_table(table, item_ids))
            common.waiting()
            os.system("clear")

        elif choice == "5":
            os.system("clear")
            print("Get the customer's id by the id of a game\n")
            file_name = common.get_file()
            if file_name == "":
                file_name = file
            table = common.get_table_from_file(file_name)
            terminal_view.print_table(table, title_list)
            sale_id = common.get_input("Enter the id of a game: ")
            print(sales.get_customer_id_by_sale_id_from_table(table, sale_id))
            common.waiting()
            os.system("clear")

        elif choice == "6":
            file_name = common.get_file()
            if file_name == "":
                file_name = file
            table = common.get_table_from_file(file_name)
            ids_of_all_customers = sales.get_all_customer_ids_from_table(table)
            print("ids of all customers who purchased games:\n",
                  ids_of_all_customers)
            common.waiting()
            os.system("clear")

        elif choice == "7":
            file_name = common.get_file()
            if file_name == "":
                file_name = file
            table = common.get_table_from_file(file_name)
            sale_ids_of_all_customers = sales.get_all_sales_ids_for_customer_ids_form_table(
                table)
            print("Sale ids of all customers:\n\n", sale_ids_of_all_customers)
            common.waiting()
            os.system("clear")

        elif choice == "8":
            file_name_sales = common.get_double_file(
                "Choose a file with sales: ")
            if file_name_sales == "":
                file_name_sales = file
            file_name_customer = common.get_double_file(
                "Choose a file with customers: ")
            if file_name_customer == "":
                file_name_customer = "model/crm/customers.csv"
            table_from_customers = common.get_table_from_file(
                file_name_customer)
            table_from_sales = common.get_table_from_file(file_name_sales)
            last_buyer = sales.get_the_last_buyer_name(table_from_customers,
                                                       table_from_sales)
            print("Owner of a recently sold game: ", last_buyer)
            common.waiting()
            os.system("clear")

        elif choice == "9":
            file_name = common.get_file()
            if file_name == "":
                file_name = file
            table = common.get_table_from_file(file_name)
            last_buyer_id = sales.get_the_last_buyer_id(table)
            print("Owner's id of a recently sold game: ", last_buyer_id)
            common.waiting()
            os.system("clear")

        elif choice == "10":
            file_name_sales = common.get_double_file(
                "Choose a file with sales: ")
            if file_name_sales == "":
                file_name_sales = file
            file_name_customer = common.get_double_file(
                "Choose a file with customers: ")
            if file_name_customer == "":
                file_name_customer = "model/crm/customers.csv"
            table_from_customers = common.get_table_from_file(
                file_name_customer)
            table_from_sales = common.get_table_from_file(file_name_sales)
            the_most_frequent_buyers = sales.get_the_most_frequent_buyers_names(
                table_from_customers, table_from_sales, num=1)
            print("The most frequent buyers:\n", the_most_frequent_buyers)
            common.waiting()
            os.system("clear")

        elif choice == "11":
            file_name = common.get_file()
            if file_name == "":
                file_name = file
            table = common.get_table_from_file(file_name)
            the_most_frequent_buyers_ids = sales.get_the_most_frequent_buyers_ids(
                table, num=1)
            print("ids of the most frequent buyers:\n",
                  the_most_frequent_buyers_ids)
            common.waiting()
            os.system("clear")

        elif choice == "12":
            os.system("clear")
            print("Get the customer by id\n")
            file_name = common.get_file()
            if file_name == "":
                file_name = "model/crm/customers.csv"
            table = common.get_table_from_file(file_name)
            terminal_view.print_table(
                table, ["* id", "* name", "* email", "* subscribed"])
            identification = common.get_input("Enter the id: ")
            print(crm.get_name_by_id_from_table(table, identification))
            common.waiting()
            os.system("clear")

        else:
            if choice != "0":
                terminal_view.print_error_message("There is no such choice.\n")
                common.waiting()
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_list = [
        "* ID", "* Name of item", "* Manufacturer", "* Year of purchase",
        "* Years it can be used"
    ]

    options = [
        "Add new record to table",
        "Remove a record with a given id from the table",
        "Update specified record in the table",
        "Items that have not exceeded their durability yet",
        "Average durability for each manufacturer", "Print table"
    ]
    os.system('clear')
    file = "model/inventory/inventory.csv"
    choice = None
    while choice != "0":
        terminal_view.print_menu("What do you want to do: ", options,
                                 "Back to main menu")
        choice = terminal_view.get_choice(options)
        if choice == "1":
            common.all_add(title_list, file)
        elif choice == "2":
            common.all_remove(title_list, file)
        elif choice == "3":
            common.all_updates(title_list, file)
        elif choice == "4":
            file_name = common.get_input("Choose a file: ")
            if file_name == "":
                file_name = file
            table = common.get_table_from_file(file_name)
            items_with_available_durability = inventory.get_available_items(
                table)
            os.system("clear")
            print("Items that have not exceeded their durability:\n",
                  items_with_available_durability)
            common.waiting()
            os.system("clear")
        elif choice == "5":
            file_name = common.get_input("Choose a file: ")
            if file_name == "":
                file_name = "model/store/games.csv"
            table = common.get_table_from_file(file_name)
            average_durability = inventory.get_average_durability_by_manufacturers(
                table)
            os.system("clear")
            print("Average durability times for each manufacturer:\n",
                  average_durability)
            common.waiting()
            os.system("clear")
        elif choice == "6":
            common.all_print_table(title_list, file)

        else:
            if choice != "0":
                terminal_view.print_error_message("There is no such choice.")
Exemplo n.º 20
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
    options = [
        "View the last buyer name", "View the last buyer ID",
        "View customer name and money spent",
        "View customer ID and money spent",
        "View the most frequent buyer name", "View the most frequent buyer ID"
    ]

    title_list = ["id", "customer", "Tittle", "price", "month", "day", "year"]
    file_name = 'data_analyser/buyers.csv'

    table = data_manager.get_table_from_file(file_name)
    terminal_view.print_primitive_logo()
    terminal_view.print_menu("Choose option:", options, "Back to main menu")
    choice = None
    while choice != "0":
        table = data_manager.get_table_from_file(file_name)
        choice = terminal_view.get_choice()
        os.system('clear')
        terminal_view.print_primitive_logo()
        if choice == "1":
            terminal_view.print_result(
                data_analyser.get_the_last_buyer_name_or_id(table, True))
            terminal_view.print_menu("Choose option:", options,
                                     "Back to main menu")
        elif choice == "2":
            terminal_view.print_result(
                data_analyser.get_the_last_buyer_name_or_id(table, False))
            terminal_view.print_menu("Choose option:", options,
                                     "Back to main menu")
        elif choice == "3":
            terminal_view.print_result(
                data_analyser.get_customer_money_spent_id_or_name(table, True))
            terminal_view.print_menu("Choose option:", options,
                                     "Back to main menu")
        elif choice == "4":
            terminal_view.print_result(
                data_analyser.get_customer_money_spent_id_or_name(
                    table, False))
            terminal_view.print_menu("Choose option:", options,
                                     "Back to main menu")
        elif choice == "5":
            terminal_view.print_result(
                data_analyser.get_the_most_frequent_buyers_id_or_name(
                    table, True))
            terminal_view.print_menu("Choose option:", options,
                                     "Back to main menu")
        elif choice == "6":
            terminal_view.print_result(
                data_analyser.get_the_most_frequent_buyers_id_or_name(
                    table, False))
            terminal_view.print_menu("Choose option:", options,
                                     "Back to main menu")