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.")
Esempio n. 2
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 = [
        "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.")
Esempio n. 4
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
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.")
Esempio n. 6
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 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.")
def make_crud(crud_module, list_labels, list_options, max_id, table,
              user_choice):
    list_labels_buff = []
    test = sum(
        [1 for item in list_labels if item[1] in ['month', 'day', 'year']])
    # for item in list_labels:
    # 	if item[1] in ['month', 'day', 'year']:
    # 		test += 1

    if test == 3 and user_choice in ['2', '4']:
        for index, item in enumerate(list_labels):
            if item[1] == 'month':
                list_labels_buff.append(['Date', 'date'])
            elif item[1] in ['year', 'day']:
                continue
            else:
                list_labels_buff.append(item)
        list_labels = list_labels_buff
    if user_choice == '1':
        terminal_view.print_table(table, list_labels)
    elif user_choice == '2':
        add(list_labels, list_options, table, crud_module)
    elif user_choice == '3':
        remove(list_options, max_id, table, crud_module)
    elif user_choice == '4':
        update(list_labels, list_options, max_id, table, crud_module)
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.")
def all_print_table(title_list, file):
    file_name = get_input("Choose a file: ")
    if file_name == "":
        file_name = file
    table = get_table_from_file(file_name)
    terminal_view.print_table(table, title_list)
    waiting()
    os.system("clear")
def updating(table, table_headers, id, filename, columns_headers,
             ask_information):
    terminal_view.print_table(table, table_headers)
    id = get_id_from_user()
    record = generate_record(table, columns_headers, ask_information, filename)
    accounting.update(table, id[0], record)
    terminal_view.print_table(table, table_headers)
    common.write_table_to_file(filename, table)
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
Esempio 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
	"""
	
	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.")
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.")
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")
Esempio n. 16
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 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
Esempio n. 18
0
def update_item(link_to_csv, labels):
    table = data_manager.get_table_from_file(link_to_csv)

    terminal_view.print_table(table, labels)
    what_id_edit = terminal_view.get_inputs(
        ["Ids' number: "], 'What position (by id) do you want edit: ')

    for record in table:
        if str(record[0]) == what_id_edit[0]:
            terminal_view.print_result(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
    """

    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
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 data", "Remove data", "Update data",
        "The customer ID with the Longest name", "Newsletter subscription",
        "Customer\'s name with the given ID"
    ]
    common_options = [
        "Name: ", "E-mail: ", "Newsletter subscribtion ('1'-yes or '0'-no): "
    ]
    link_for_csv = "model/crm/customers.csv"
    title_list = ["ID", "Name", "E-mail", "Newsletter subscribtion"]
    choice = None
    dont_clear = False
    while choice != '0':
        if not dont_clear:
            os.system("clear")
            table = data_manager.get_table_from_file(link_for_csv)
            terminal_view.print_table(table, title_list)
        choice = terminal_view.get_choice_submenu(options)
        dont_clear = False
        if choice == '1':
            common.add(link_for_csv, common_options)
        elif choice == '2':
            common.remove(link_for_csv)
        elif choice == '3':
            common.update(link_for_csv, common_options)
        elif choice == '4':
            terminal_view.print_result(
                crm.get_longest_name_id(table),
                'ID of the customer with the Longest name: ')
            dont_clear = True
        elif choice == '5':
            table_subscription = crm.get_subscribed_emails(table)
            terminal_view.print_result(
                table_subscription,
                'Customers who has subscribed to the newsletter: ')
            dont_clear = True
        elif choice == '6':
            ID = terminal_view.get_input("ID: ", "Please enter ID: ")
            terminal_view.print_result(
                crm.get_name_by_id_from_table(table, ID),
                "Customer\'s name by given ID: ")
            dont_clear = True
        else:
            terminal_view.print_error_message(
                "There is no such choice, please try again")
Esempio n. 21
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_headers = [
        'ID', 'Name', 'Manufacturer', 'Purchase Year', 'Durability'
    ]
    choice = None
    filename = 'model/inventory/inventory.csv'
    columns_headers = ['Name', 'Manufacturer', 'Purchase Year', 'Durability']
    ask_information = "Please provide your personal information"
    common.print_art(0)
    while choice != "0":
        choice = terminal_view.get_submenu_choice([
            'Add', 'Remove', 'Update',
            "Items that have not exceeded their durability yet",
            "Average durability by manufactirers"
        ])
        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)
            availible_items = inventory.get_available_items(table)
            terminal_view.print_result(
                "Items that have not exceeded their durability yet",
                availible_items)
        elif choice == "5":
            common.clear_terminal()
            terminal_view.print_table(table, table_headers)
            average_durability = inventory.get_average_durability_by_manufacturers(
                table)
            terminal_view.print_result("Average durability by manufactirers:",
                                       average_durability)
        elif int(choice) >= 6:
            common.clear_terminal()
            terminal_view.print_error_message("There is no such choice.")
Esempio n. 22
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: ")
Esempio n. 23
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: ")
Esempio 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
    """

    table_headers = ['ID', 'Name', 'Birth Year']
    choice = None
    filename = 'model/hr/persons.csv'
    columns_headers = ['Name', 'Birth Year']
    ask_information = "Please provide your personal information"

    common.print_art(0)
    while choice != "0":
        choice = terminal_view.get_submenu_choice([
            'Add', 'Remove', 'Update', 'Get oldest person',
            'People closest to average age'
        ])
        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)
            hr_result = hr.get_oldest_person(table)
            terminal_view.print_result("\nThe oldest people are/ person is",
                                       hr_result)
        elif choice == "5":
            common.clear_terminal()
            terminal_view.print_table(table, table_headers)
            closest_to_average_people = hr.get_persons_closest_to_average(
                table)
            terminal_view.print_result("People closest to average age: ",
                                       closest_to_average_people)

        elif int(choice) >= 6:
            common.clear_terminal()
            terminal_view.print_error_message("There is no such choice.")
def run():
    options = ["Add", "Remove", "Update", "Lowest price item ID", "Items sold between", "Game title by ID", "All the Customer\'s IDs", "The sales of each customer", "The sales of each customer", "The number of sales of each customer", "The number of sales of each customer: "]
    common_options = ["Title: ", "Price: ", "Month: ", "Day: ", "Year: "]
    link_for_csv = "model/sales/sales.csv"
    title_list = ["ID", "Title", "Price", "Month", "Day", "Year", "Customer ID"]
    choice = None
    dont_clear = False
    while choice != '0':
        if not dont_clear:
            os.system("clear")
            table = data_manager.get_table_from_file(link_for_csv)
            terminal_view.print_table(table, title_list)
        choice = terminal_view.get_choice_submenu(options)
        dont_clear = False
        if choice == '1':
            common.add(link_for_csv, common_options)
        elif choice == '2':
            common.remove(link_for_csv)
        elif choice == '3':
            common.update(link_for_csv, common_options)
        elif choice == '4':
            lowest_price = sales.get_lowest_price_item_id(table)
            terminal_view.print_result(lowest_price, 'Lowest price game is: ')
            dont_clear = True
        elif choice == '5':
            dates_to_input = ['From month: ', 'From day: ', 'From year: ', 'To month:', 'To day: ', "To year: "]
            inputs = terminal_view.get_input(dates_to_input, "Please input appropriate data.")
            answer = sales.get_items_sold_between(table, int(inputs[0]), int(inputs[1]), int(inputs[2]), int(inputs[3]),
                                                  int(inputs[4]), int(inputs[5]))
            terminal_view.print_table(answer, title_list)
            dont_clear = True
        elif choice == '6':
            dates_to_input = 'Input ID: '
            inputs = terminal_view.get_input(dates_to_input, 'Please input appropriate data.')
            answer = sales.get_title_by_id(inputs)
            terminal_view.print_result(answer, 'Game title is: ')
            dont_clear = True
        elif choice == "7":
            terminal_view.print_result(sales.get_all_customer_ids_from_table(table), 'All the Customer\'s ID: ')
            dont_clear = True
        elif choice == "8":
            terminal_view.print_result(sales.get_all_sales_ids_for_customer_ids(), "The sales of each customer: ")
            dont_clear = True
        elif choice == "9":
            terminal_view.print_result(sales.get_all_sales_ids_for_customer_ids_form_table(table), "The sales of each customer: ")
            dont_clear = True
        elif choice == "10":
            terminal_view.print_result(sales.get_num_of_sales_per_customer_ids(), "The number of sales of each customer: ")
            dont_clear = True
        elif choice == "11":
            terminal_view.print_result(sales.get_num_of_sales_per_customer_ids_from_table(table), "The number of sales of each customer: ")
            dont_clear = True
Esempio 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
    """
    options = [
        'Add item', 'Edit item', 'Remove item',
        'Which items have not exceeded their durability yet',
        'What are the average durability times for each manufacturer'
    ]
    link_to_csv = 'model/inventory/inventory.csv'
    common_options = [
        'Name of item: ', 'Manufacturer: ', 'Year of purchase: ',
        'Years it can be used: '
    ]
    title_list = [
        "Id", "Name", "Manufacturer", "Year of purchase",
        "Years it can be used"
    ]
    choice = None
    dont_clear = False
    while choice != "0":
        if not dont_clear:
            os.system("clear")
            table = data_manager.get_table_from_file(link_to_csv)
            terminal_view.print_table(table, title_list)
        choice = terminal_view.get_choice_submenu(options)
        dont_clear = False
        if choice == "1":
            common.add(link_to_csv, common_options)
        elif choice == "2":
            common.update(link_to_csv, common_options)
        elif choice == "3":
            common.remove(link_to_csv)
        elif choice == "4":
            os.system("clear")
            table_to_print = inventory.get_available_items(table)
            terminal_view.print_table(table_to_print, labels)

            dont_clear = True
        elif choice == "5":
            terminal_view.print_result(
                inventory.get_average_durability_by_manufacturers(table),
                '\nWhat are the average durability times for each manufacturer: '
            )
            dont_clear = True
        else:
            terminal_view.print_error_message("There is no such choice.")
def all_remove(title_list, file):
    file_name = get_input("Choose a file: ")
    if file_name == "":
        file_name = file
    table = get_table_from_file(file_name)
    terminal_view.print_table(table, title_list)
    id_ = get_input("Enter id of a record you want to remove: ")
    table = remove(table, id_)
    write_table_to_file(file_name, table)
    os.system("clear")
    terminal_view.gprint('*** Record has been removed ***')
    waiting()
    os.system("clear")
def all_add(title_list, file):
    file_name = get_input("Choose a file: ")
    if file_name == "":
        file_name = file
    table = get_table_from_file(file_name)
    terminal_view.print_table(table, title_list)
    record = terminal_view.get_inputs(title_list, "Enter data: ")
    table = add(table, record)
    write_table_to_file(file_name, table)
    os.system("clear")
    terminal_view.gprint('*** Record has been added ***')
    waiting()
    os.system("clear")
Esempio n. 29
0
def add_item(link_to_csv, labels):

    new_record = terminal_view.get_inputs([
        'Name of item: ', 'Manufacturer: ', 'Year of purchase: ',
        'Years it can be used: '
    ], 'Please input information about platform: ')

    table = data_manager.get_table_from_file(link_to_csv)
    new_record.insert(0, model.common.generate_random(table))
    ready_table = inventory.add(table, new_record)
    data_manager.write_table_to_file(link_to_csv, ready_table)

    terminal_view.print_table(ready_table, labels)
Esempio n. 30
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 data", "Remove data", "Update data",
        "Year with the highest profit", "The average profit for a given year"
    ]
    common_options = [
        "Month: ", "Day: ", "Year: ",
        "Income (enter: 'in') or Outflow(enter:'out') money: ", "Amount: "
    ]
    link_for_csv = 'model/accounting/items.csv'
    title_list = [
        "ID", "Month", "Day", "Year", "Income or Outflow money", "Amount"
    ]
    choice = None
    dont_clear = False
    while choice != "0":
        if not dont_clear:
            os.system("clear")
            table = data_manager.get_table_from_file(link_for_csv)
            terminal_view.print_table(table, title_list)
        choice = terminal_view.get_choice_submenu(options)
        dont_clear = False
        if choice == "1":
            common.add(link_for_csv, common_options)
        elif choice == "2":
            common.remove(link_for_csv)
        elif choice == "3":
            common.update(link_for_csv, common_options)
        elif choice == "4":
            terminal_view.print_result(accounting.which_year_max(table),
                                       "Year with the highest profit: ")
            dont_clear = True
        elif choice == "5":
            year = int(
                terminal_view.get_input(
                    "Year: ", "Enter a year to find out an average profit: "))
            terminal_view.print_result(
                accounting.avg_amount(table, year),
                'The average profit for a given year: ')
            dont_clear = True
        else:
            terminal_view.print_error_message(
                "There is no such choice, please try again")