Exemplo n.º 1
0
def start_module():
    """
    Starts this module and displays its menu.
     * User can access default special features from here.
     * User can go back to main menu from here.

    Returns:
        None
    """
    common.clear()
    special_functions = [
        "Show table", "Add elements", "Remove element by it's ID",
        "Update an element by it's ID", "Get longest name ID",
        "Get subscribed e-mails"
    ]

    table = data_manager.get_table_from_file("crm/customers_test.csv")
    ui.print_menu("Customer Relationship Management MENU", special_functions,
                  "go back to Main Menu.")
    choice = ui.get_inputs(" ", "What's your choice?")
    choice = common.check_one_input_for_number(choice, " ",
                                               "What's your choice?")

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

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

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

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

        elif choice == 5:  #ID cust
            ui.print_result(get_longest_name_id(table),
                            "The ID of the customer is:")

        elif choice == 6:  #subscribed
            result = get_subscribed_emails(table)
            ui.print_result(
                result, "These customers have subscribed to the news letter:")

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

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

    common.clear()
Exemplo n.º 2
0
def start_module():
    """
    Starts this module and displays its menu.
     * User can access default special features from here.
     * User can go back to main menu from here.

    Returns:
        None
    """
    common.clear()
    special_functions = [
        "Show table", "Add elements", "Remove element by it's ID",
        "Update an element", "Get counts by manufacturer",
        "Get averege products"
    ]

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

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

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

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

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

        elif choice == 5:  #counts
            ui.print_result(
                get_counts_by_manufacturers(table),
                "This many different kinds of games are available for each manufacturer:"
            )

        elif choice == 6:  #avg by manufac
            manufacturer = ui.get_inputs(" ", "Add the manufacturer")
            manufacturer = manufacturer[0]
            ui.print_result(
                get_average_by_manufacturer(table, manufacturer),
                "The average amount of games in stock of a given manufacturer is:"
            )

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

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

    common.clear()
def start_module():
    """
    Starts this module and displays its menu.
     * User can access default special features from here.
     * User can go back to main menu from here.

    Returns:
        None
    """
    common.clear()
    special_functions=["Show table",
    "Add elements",
    "Remove element by it's ID",
    "Update an element",
    "Get which year has the highest profit",
    "Get what is the average profit in a given year?"]

    table=data_manager.get_table_from_file("accounting/items_test.csv")
    ui.print_menu("Accounting Manager MENU",special_functions,"go back to Main Menu.")
    choice=ui.get_inputs(" ","What's your choice?")
    choice=common.check_one_input_for_number(choice," ","What's your choice?")
    
    while choice!=0:
        if choice==1: #show, choice[0] because from the user inputs we get lists 
            show_table(table)

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

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

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

        elif choice==5: #max
            ui.print_result(which_year_max(table),"The max profit's year: ")

        elif choice==6: #avg
            year=ui.get_inputs(" ","Add the year")
            year=year[0]
            result=avg_amount(table,year)
            if result!=None:
                ui.print_result(result,"The average profit in {0} is: ".format(year))

        else:
            ui.print_error_message("Wrong input!")
        
        ui.print_menu("Accounting Manager MENU",special_functions,"go back to Main Menu.")
        choice=ui.get_inputs(" ","What's your choice?")
        choice=common.check_one_input_for_number(choice," ","What's your choice?")
        
        common.clear()
        
    common.clear()
Exemplo n.º 4
0
def start_module():
    """
    Starts this module and displays its menu.
     * User can access default special features from here.
     * User can go back to main menu from here.

    Returns:
        None
    """
    common.clear()
    special_functions = [
        "Show table", "Add elements", "Remove element by it's ID",
        "Update an element", "Get lowest price ID",
        "Get items sold between two dates"
    ]

    table = data_manager.get_table_from_file("sales/sales_test.csv")
    ui.print_menu("Sales Manager MENU", special_functions, "")
    choice = ui.get_inputs(" ", "What's your choice?")
    choice = common.check_one_input_for_number(choice, " ",
                                               "What's your choice?")

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

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

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

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

        elif choice == 5:  #lowest price item id
            ui.print_result(
                get_lowest_price_item_id(table),
                "The ID of the item that was sold for the lowest price is:")

        elif choice == 6:  #avg
            list = ["year", "month", "day"]
            date1 = []
            date2 = []
            for i in range(3):
                value = int(
                    ui.get_inputs(" ", "Add the first date's {}".format(
                        list[i]))[0])

                if i == 0:  # years
                    while not (value > 0):

                        ui.print_error_message("Wrong attribute")
                        value = ui.get_inputs(
                            " ", "Add the first date's {}".format(list[i]))
                        value = common.check_one_input_for_number(
                            value, " ",
                            "Add the first date's {}".format(list[i]))
                    date1.append(value)

                elif i == 1:  #months
                    while not (value > 0) or not (value < 13):
                        ui.print_error_message("Wrong attribute")
                        value = ui.get_inputs(
                            " ", "Add the first date's {}".format(list[i]))
                        value = common.check_one_input_for_number(
                            value, " ",
                            "Add the first date's {}".format(list[i]))
                    date1.append(value)

                elif i == 2:  # days
                    if common.leap_year_checker(date1[0]) is True:
                        month_to_day[2] = 29
                    while not (value > 0) or not (value <=
                                                  month_to_day[date1[1]]):
                        ui.print_error_message("Wrong attribute")
                        value = ui.get_inputs(
                            " ", "Add the first date's {}".format(list[i]))
                        value = common.check_one_input_for_number(
                            value, " ",
                            "Add the first date's {}".format(list[i]))
                    date1.append(value)
                    month_to_day[2] = 28
            for i in range(3):
                value = ui.get_inputs(
                    " ", "Add the second date's {}".format(list[i]))
                value = common.check_one_input_for_number(
                    value, " ", "Add the second date's {}".format(list[i]))
                if i == 0:
                    while not (value > 0):

                        ui.print_error_message("Wrong attribute")
                        value = ui.get_inputs(
                            " ", "Add the second date's {}".format(list[i]))
                        value = common.check_one_input_for_number(
                            value, " ",
                            "Add the second date's {}".format(list[i]))
                    date2.append(value)

                elif i == 1:
                    while not (value > 0) or not (value < 13):
                        ui.print_error_message("Wrong attribute")
                        value = ui.get_inputs(
                            " ", "Add the second date's {}".format(list[i]))
                        value = common.check_one_input_for_number(
                            value, " ",
                            "Add the second date's {}".format(list[i]))
                    date2.append(value)

                elif i == 2:
                    if common.leap_year_checker(int(date2[0])) == True:
                        month_to_day[2] = 29
                    while not (value > 0) or not (value <=
                                                  month_to_day[date1[1]]):
                        ui.print_error_message("Wrong attribute")
                        value = ui.get_inputs(
                            " ", "Add the second date's {}".format(list[i]))
                        value = common.check_one_input_for_number(
                            value, " ",
                            "Add the second date's {}".format(list[i]))

                    date2.append(value)
                    month_to_day[2] = 28
            result = get_items_sold_between(table, date1[1], date1[2],
                                            date1[0], date2[1], date2[2],
                                            date2[0])

            ui.print_result(result,
                            "These items are sold between the given dates:")

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

        ui.print_menu("Sales Manager MENU", special_functions, "")
        choice = ui.get_inputs(" ", "What's your choice?")
        choice = common.check_one_input_for_number(choice, " ",
                                                   "What's your choice?")
        common.clear()

    common.clear()
Exemplo n.º 5
0
def start_module():
    """
    Starts this module and displays its menu.
     * User can access default special features from here.
     * User can go back to main menu from here.

    Returns:
        None
    """

    common.clear()
    special_functions = [
        "Latest buyer name", "Last buyer ID",
        "The buyer name spent most and the money spent",
        "Get the buyer ID spent most and the money spent",
        "Get the most frequent buyers names",
        "Get the most frequent buyers IDs", "Get customer without purchase"
    ]

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

    while choice != 0:
        if choice == 1:
            ui.print_result(get_the_last_buyer_name(),
                            "The latest buyer name: ")

        elif choice == 2:
            ui.print_result(get_the_last_buyer_id(), "Last buyer's ID: ")

        elif choice == 3:
            ui.print_result(
                get_the_buyer_name_spent_most_and_the_money_spent(),
                "The buyer name is: ")

        elif choice == 4:
            ui.print_result(get_the_buyer_id_spent_most_and_the_money_spent(),
                            "The buyer's ID is: ")

        elif choice == 5:
            ui.print_result(get_the_most_frequent_buyers_names(),
                            "The most frequent buyers names: ")

        elif choice == 6:
            ui.print_result(get_the_most_frequent_buyers_ids(),
                            "The most frequent buyers IDs: ")

        elif choice == 7:
            ui.print_result(customer_without_purchase(), "The customers: ")

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

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

    common.clear()
Exemplo n.º 6
0
def start_module():
    """
    Starts this module and displays its menu.
     * User can access default special features from here.
     * User can go back to main menu from here.

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

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

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

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

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

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

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

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

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

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

    common.clear()
Exemplo n.º 7
0
def start_module():
    """
    Starts this module and displays its menu.
     * User can access default special features from here.
     * User can go back to main menu from here.

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

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

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

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

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

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

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

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

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

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

    common.clear()