Esempio n. 1
0
def run():

    title = 'Main menu'
    options = [
        "Store manager", "Human resources manager", "Inventory manager",
        "Accounting manager", "Sales manager",
        "Customer Relationship Management (CRM)"
    ]
    exit_message = "Exit program"

    choice = None
    while choice != "0":
        common.clear()
        choice = terminal_view.get_choice(title, options, exit_message)
        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 != 0:
            terminal_view.print_error_message("There is no such choice.")
Esempio 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
    """

    common.clear()
    title = 'Custom Relationship Mmanager menu'
    options = ["Add new record to table",
               "Remove a record with a given id from the table.",
               "Updates specified record in the table.",
               "What is the id of the customer with the longest name?",
               "Which customers has subscribed to the newsletter?"]
    exit_message = "Back to main menu"

    title_list = ["ID", "NAME", "EMAIL", "SUBSCRIBED"]
    table = crm.data_manager.get_table_from_file('model/crm/customers.csv')

    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 = crm.add(table, record)
            crm.data_manager.write_table_to_file('model/crm/customers.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 = crm.remove(table, id_)
            crm.data_manager.write_table_to_file('model/crm/customers.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 = crm.update(table, id_, record)
            crm.data_manager.write_table_to_file('model/crm/customers.csv', updated_table)
            common.exit_prompt()
            common.clear()
        elif choice == "4":
            label = "The id of the customer with the longest name is: "
            result = crm.get_longest_name_id(table)
            terminal_view.print_result(result, label)
            common.exit_prompt()
            common.clear()
        elif choice == "5":
            label = "Customers that has been subscribed to the newsletter: "
            result = crm.get_subscribed_emails(table)
            terminal_view.print_result(result, label)
            common.exit_prompt()
            common.clear()
        elif choice != 0:
            terminal_view.print_error_message("There is no such choice.")
        common.exit_prompt()
        common.clear()
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 = 'Store menu'
    options = [
        "Add new record to table",
        "Remove a record with a given id from the table.",
        "Updates specified record in the table.",
        "How many different kinds of game are available of each manufacturer?",
        "What is the average amount of games in stock of a given manufacturer?"
    ]
    exit_message = "Back to main menu"
    title_list = ["ID", "TITLE", "MANUFACTURER", "PRICE", "IN STOCK"]
    table = store.data_manager.get_table_from_file('model/store/games.csv')

    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 = store.add(table, record)
            store.data_manager.write_table_to_file('model/store/games.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 = store.remove(table, id_)
            store.data_manager.write_table_to_file('model/store/games.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 = store.update(table, id_, record)
            store.data_manager.write_table_to_file('model/store/games.csv',
                                                   updated_table)
            common.exit_prompt()
            common.clear()
        elif choice == "4":
            label = "The kinds of game that are available of each manufacturer: "
            result = store.get_counts_by_manufacturers(table)
            terminal_view.print_result(result, label)
            common.exit_prompt()
            common.clear()
        elif choice == "5":
            manufacturer = terminal_view.get_inputs(
                ['Manufacturer : '], 'Please select a manufacturer :')
            manufacturer = manufacturer[0]
            result = str(store.get_average_by_manufacturer(
                table, manufacturer))
            label = "The average amount of games in stock of {} ".format(
                manufacturer)
            terminal_view.print_result(result, label)
            common.exit_prompt()
            common.clear()
        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
    """

    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.")
Esempio n. 5
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
    """
    common.clear()
    title = 'Accounting  menu'
    options = [
        "Add new record to table",
        "Remove a record with a given id from the table.",
        "Updates specified record in the table.",
        "Which year has the highest profit? (profit = in - out)",
        "What is the average (per item) profit in a given year? [(profit)/(items count)]"
    ]
    exit_message = "Back to main menu"
    title_list = ["ID", "MONTH", "DAY", "YEAR", 'TYPE', 'DURABILITY']
    table = accounting.data_manager.get_table_from_file(
        'model/accounting/items.csv')

    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 = accounting.add(table, record)
            accounting.data_manager.write_table_to_file(
                'model/accounting/items.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 = accounting.remove(table, id_)
            accounting.data_manager.write_table_to_file(
                'model/accounting/items.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 = accounting.update(table, id_, record)
            accounting.data_manager.write_table_to_file(
                'model/accounting/items.csv', updated_table)
            common.exit_prompt()
            common.clear()
        elif choice == "4":
            label = "Which year has the highest profit?"
            result = str(accounting.which_year_max(table))
            terminal_view.print_result(result, label)
            common.exit_prompt()
            common.clear()
        elif choice == "5":
            year = terminal_view.get_inputs(['year : '],
                                            'Please give  a year :')
            year = year[0]
            result = str(accounting.avg_amount(table, year))
            label = "the average (per item) profit in {} ".format(year)
            terminal_view.print_result(result, label)
            common.exit_prompt()
            common.clear()
        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
    """
    common.clear()
    title = 'Sales menu'
    options = [
        "Add new record to table",
        "Remove a record with a given id from the table.",
        "Updates specified record in the table.",
        "What is the id of the item that was sold for the lowest price?",
        "Which items are sold between two given dates? (from_date < sale_date < to_date)"
    ]
    exit_message = "Back to main menu"
    title_list = ["ID", "TITLE", "PRICE", "MONTH", 'DAY', 'YEAR']
    table = sales.data_manager.get_table_from_file('model/sales/sales.csv')

    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 = sales.add(table, record)
            sales.data_manager.write_table_to_file('model/sales/sales.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 = sales.remove(table, id_)
            sales.data_manager.write_table_to_file('model/sales/sales.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 = sales.update(table, id_, record)
            sales.data_manager.write_table_to_file('model/sales/sales.csv',
                                                   updated_table)
            common.exit_prompt()
            common.clear()
        elif choice == "4":
            label = "What is the id of the item that was sold for the lowest price?"
            result = str(sales.get_lowest_price_item_id(table))
            terminal_view.print_result(result, label)
            common.exit_prompt()
            common.clear()
        elif choice == "5":
            label = "Which items are sold between two given dates? (from_date < sale_date < to_date)"
            month_from = terminal_view.get_inputs(
                ['Month from'], "Please give starting month.")
            day_from = terminal_view.get_inputs(['Day from'],
                                                "Please give starting day.")
            year_from = terminal_view.get_inputs(['Year from'],
                                                 "Please give starting year.")
            month_to = terminal_view.get_inputs(['Month to'],
                                                "Please give ending month.")
            day_to = terminal_view.get_inputs(['Day to'],
                                              "Please give ending day.")
            year_to = terminal_view.get_inputs(['Year to'],
                                               "Please give ending year.")
            month_from = int(month_from[0])
            day_from = int(day_from[0])
            year_from = int(year_from[0])
            month_to = int(month_to[0])
            day_to = int(day_to[0])
            year_to = int(year_to[0])
            result = str(
                sales.get_items_sold_between(table, month_from, day_from,
                                             year_from, month_to, day_to,
                                             year_to))
            terminal_view.print_result(result, label)
            common.exit_prompt()
            common.clear()
        elif choice != 0:
            terminal_view.print_error_message("There is no such choice.")
Esempio n. 7
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
    """

    common.clear()
    title = 'Inventory menu'
    options = [
        "Add new record to table",
        "Remove a record with a given id from the table.",
        "Updates specified record in the table.",
        "Which items have not exceeded their durability yet?",
        "What are the average durability times for each manufacturer?"
    ]
    exit_message = "Back to main menu"
    title_list = ["ID", "NAME", "MANUFACTURER", "PURCHASE YEAR", 'DURABILITY']
    table = inventory.data_manager.get_table_from_file(
        'model/inventory/inventory.csv')

    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 = inventory.add(table, record)
            inventory.data_manager.write_table_to_file(
                'model/inventory/inventory.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 = inventory.remove(table, id_)
            inventory.data_manager.write_table_to_file(
                'model/inventory/inventory.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 = inventory.update(table, id_, record)
            inventory.data_manager.write_table_to_file(
                'model/inventory/inventory.csv', updated_table)
            common.exit_prompt()
            common.clear()
        elif choice == "4":
            label = "The items that have not exceeded their durability yet: "
            result = inventory.get_available_items(table)
            terminal_view.print_result(result, label)
            common.exit_prompt()
            common.clear()
        elif choice == "5":
            label = "What are the average durability times for each manufacturer?"
            result = inventory.get_average_durability_by_manufacturers(table)
            terminal_view.print_result(result, label)
            common.exit_prompt()
            common.clear()
        elif choice != 0:
            terminal_view.print_error_message("There is no such choice.")