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 get_average_by_manufacturer(table, manufacturer): """ Question: What is the average amount of games in stock of a given manufacturer? Args: table (list): data table to work on manufacturer (str): Name of manufacturer Returns: number """ games_counter = 0 sum_games_avb = 0 for game in table: games_in_stock = game[4] manufacturer_in_list = game[2] if manufacturer_in_list == manufacturer: games_counter += 1 sum_games_avb += int(games_in_stock) try: avg_games = sum_games_avb/games_counter except ZeroDivisionError: terminal_view.print_error_message('There is no such position in table') return avg_games
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(): 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.")
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 = [ 'Human resources', 'Show all people', 'Add', 'Remove', 'Update', 'Get oldest person', 'Get persons closest to average', 'Exit to main menu' ] list_labels = [['Name', 'name'], ['Birth year', 'year']] data_file = "model/hr/persons.csv" crud_module = hr while True: table = data_manager.get_table_from_file(data_file) max_id = len(table) 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': terminal_view.print_result(hr.get_oldest_person(table), 'Get oldest person:') elif user_choice == '6': terminal_view.print_result( hr.get_persons_closest_to_average(table), 'Get persons closest to average:') elif user_choice == '0': break 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(): title = "Main Menu" options = [ "Store manager", "Human resources manager", "Inventory manager", "Accounting manager", "Sales manager", "Customer Relationship Management (CRM)" ] exit_message = "Turn off program" choice = None while choice != "0": 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() else: terminal_view.print_error_message( "You have chosen to turn off the program.")
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 run(): os.system('cls||clear') title = "Main menu\n" options = [ "(1) Store manager", "(2) Human resources manager", "(3) Inventory manager", "(4) Accounting manager", "(5) Sales manager", "(6) Customer Relationship Management (CRM)" ] exit_message = "(0) Exit program\n" argument = None choice = None while argument != "0": 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": argument = terminal_view.kutas_kurwa() else: terminal_view.print_error_message("There is no such choice.")
def run(): options = [ "Add", "Remove", "Update", "Count by manufacturer", "Average games in stock by manufacturer" ] common_options = ["Title: ", "Manufacturer: ", "Price: ", "In stock: "] file = "model/store/games.csv" title_list = ["Id", "Title", "Manufacturer", "Price", "In stock"] choice = None terminal_clear = True while choice != '0': if terminal_clear: table = common.clear_instructions(file, title_list) choice = terminal_view.get_choice_submenu(options) terminal_clear = True if choice == '1': common.add(file, common_options) elif choice == '2': common.remove(file) elif choice == '3': common.update(file, common_options) elif choice == '4': msg = "Products by manufacturer:\n" terminal_view.print_result( store.get_counts_by_manufacturers(table), msg) terminal_clear = False elif choice == '5': manufacturer = terminal_view.get_inputs( ["Manufacturer: "], "Please provide manufacturer name") msg = "Average by " + manufacturer[0] + ":" value = store.get_average_by_manufacturer(table, manufacturer[0]) terminal_view.print_result(value, msg) terminal_clear = False else: terminal_view.print_error_message("There is no such choice.")
def run(): options = ["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.")
def run(): options = ["1. Store manager", "2. Human resources manager", "3. Inventory manager", "4. Accounting manager", "5. Sales manager", "6. Customer Relationship Management (CRM)"] choice = None while choice != "0": 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() elif choice == "0": return else: terminal_view.print_error_message("There is no such choice. Choose from 1 to 6")
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(): """ 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(): """ 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'] terminal_view.get_choice(options) table = inventory.create_table() choice = None while choice != "0": choice = terminal_view.get_choice(options) if choice == "1": add_item(table) elif choice == "2": hr_controller.run() elif choice == "3": inventory_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 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(): os.system('clear') options = [ "Store manager", "Human resources manager", "Inventory manager", "Accounting manager", "Sales manager", "Customer Relationship Management (CRM)", "Data Analyser" ] choice = None while choice != "0": os.system('clear') 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() elif choice == "7": data_analyser_controller.run() elif choice == "0": os.system('clear') 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 """ title = "Human resources manager" options = [ "Add item", "Remove item", "Update item", "Show the oldest person", "Show person closest to average age" ] exit_message = "Back to main menu" title_list = [['Name'], ['Date of birth']] data_file = "model/hr/persons.csv" table = data_manager.get_table_from_file(data_file) terminal_view.print_table(table, title_list) choice = None while choice != "0": choice = terminal_view.get_choice(title, options, exit_message) if choice == "1": record = [] index = 0 inputs = terminal_view.get_inputs(title_list, title) for i in inputs: record.insert(index, i) index += 1 hr.add(table, record) data_manager.write_table_to_file(data_file, table) terminal_view.print_table(table, title_list) elif choice == "2": user_input = terminal_view.get_inputs(["Enter ID: "], "") hr.remove(table, user_input[0]) terminal_view.print_table(table, title_list) elif choice == "3": record = [] index = 0 user_input = terminal_view.get_inputs(["Enter ID: "], "") inputs = terminal_view.get_inputs(title_list, title) for i in inputs: record.insert(index, i) index += 1 hr.update(table, user_input[0], record) terminal_view.print_table(table, title_list) elif choice == "4": terminal_view.print_result(hr.get_oldest_person(table), "Oldest person") elif choice == "5": terminal_view.print_result( hr.get_persons_closest_to_average(table), "Person closest to average") else: terminal_view.print_error_message("You have chosen back to menu.")
def run(): 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", "* 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(): """ 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 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 """ 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 """ list_options = [ "1. Add new record to table", "2. Remove a record with a given id from the table", "3. Update specified record in the table", "4. Which items have not exceeded their durability yet?", "5. What are the average durability times for each manufacturer?" ] program_works = True while program_works: table = inventory.get_table() title_list = [ "ID", "NAME", "MANUFACTURER", "PURCHASE YEAR", "DURABILITY" ] terminal_view.print_table(table, title_list) answer = terminal_view.get_choice(list_options) if answer == "1": record = terminal_view.get_inputs([ "ID: ", "Name: ", "Manufacturer: ", "Purchase year: ", "Durability: " ], "Please provide information: \n") common.add(table, record) inventory.save_table(table) elif answer == "2": id_ = terminal_view.get_input("Please enter id number: ") common.remove(table, id_) inventory.save_table(table) elif answer == "3": id_ = terminal_view.get_input("Please enter id number: ") record = terminal_view.get_inputs([ "Enter ID: ", "Name of item: ", "Manufacturer: ", "Year of purchase", "Durability year" ], "Please provide new information") common.update(table, id_, record) inventory.save_table(table) elif answer == "4": inventory.get_oldest_person(table) elif answer == "5": inventory.get_average_durability_by_manufacturers(table) elif answer == "0": program_works = False else: terminal_view.print_error_message( "There is no such choice. Choose from 1 to 5") return
def run(): """ Starts this module and displays its menu. * User can access default special features from here. * User can go back to main menu from here. Returns: None """ list_options = [ "1. Add new record to table", "2. Remove a record with a given id from the table", "3. Update specified record in the table", "4. Which year has the highest profit?", "5. What is the average (per item) profit in a given year?" ] program_works = True while program_works: table = accounting.get_table() title_list = ["ID", "MONTH", "DAY", "YEAR", "TYPE", "AMOUNT"] terminal_view.print_table(table, title_list) answer = terminal_view.get_choice(list_options) if answer == "1": record = terminal_view.get_inputs([ "ID: ", "Month of the transaction: ", "Day of the transaction: ", "Year of the transaction: ", "Type - income/outflow (in.out): ", "Amount of transaction in USD: " ], "Please provide information: \n") common.add(table, record) accounting.save_table(table) elif answer == "2": id_ = terminal_view.get_input("Please enter id number: ") common.remove(table, id_) accounting.save_table(table) elif answer == "3": id_ = terminal_view.get_input("Please enter id number: ") record = terminal_view.get_inputs( ["ID: ", "Month: ", "Day: ", "Year: ", "Type: ", "Ammount: "], "Please provide new information") common.update(table, id_, record) accounting.save_table(table) elif answer == "4": accounting.which_year_max(table) elif answer == "5": accounting.avg_amount(table, year) elif answer == "0": program_works = False else: terminal_view.print_error_message( "There is no such choice. Choose from 1 to 5") return
def run(): """ 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 """ 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")
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 """ 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.")
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