def employee_edit_menu(employee): while True: print("Edit employee menu".center(30, " ")) print("=" * 30) print(f"1. Show orders handled by {employee.employee_last_name}") print(f"2. Fire {employee.employee_last_name}") print("0. Exit") selection = input_int_validation("Menu selection") if selection == 1: # ----MySQL---- # print( # ("\n".join(f"Order {count} at {order.order_date}".center(30, " ") + # f"\n{details.spare_part.description} \t quantity: {details.quantity}" # for count, order in enumerate(employee.orders, 1) for details in order.order_lines)) # ) print("\n".join( f"Order {count} at {order.order_date}".center(30, " ") + f"\n{details['spare_part'].description} \t quantity: {details['quantity']}" for count, order in enumerate(employee.orders, 1) for details in order.order_detail)) elif selection == 2: fire_employee(employee) break elif selection == 0: break
def employee_menu(): while True: print("Employee Menu".center(30, " ")) print("=" * 30) print("1. Show employees") print("2. Select employee") print("3. Add employee") print("0. Exit") selection = input_int_validation("Menu selection") if selection == 1: employees = ec.get_all_employees() print("\n".join( f"{i}. {employee.employee_first_name} {employee.employee_last_name} works at our office in " f"{employee.store.store_name}" for i, employee in enumerate(employees, 1))) elif selection == 2: select_employee_menu() elif selection == 3: add_employee_menu() elif selection == 0: break
def fire_employee(employee): while True: print(f"Give {employee.employee_last_name} reason for being fired". center(30, " ")) print("=" * 30) print("1. The smell is unbearable") print("2. That one time on the company christmas party") print("3. Your not a fan if Star Wars") print("0. Exit") selection = input_int_validation( "Thread carefully, your carisma lvl is low!") if selection == 1: fire_message(employee, selection) ec.fire_employee(employee) break elif selection == 2: fire_message(employee, selection) ec.fire_employee(employee) break elif selection == 3: fire_message(employee, selection) ec.fire_employee(employee) break elif selection == 0: print("Unable")
def find_employee_by_store(): store = search_store() print("Employees working in this store: ") print("\n".join( f"{i}. {employee.employee_first_name} {employee.employee_last_name}" for i, employee in enumerate(store.employees, 1))) selection = input_int_validation("\nChoose an employee") return store.employees[selection - 1]
def verify_employee(employee): print("OBS!".center(30, "-")) print(f"First name: {employee.employee_first_name}\n" f"Last name: {employee.employee_last_name}\n" f"Phone: {employee.employee_phone_nr}\n" f"Email: {employee.employee_email}\n" f"Store: {employee.store.store_name}\n") selection = input_int_validation( "Is the information correct?\n(1). Yes\n(2). No\n") return selection == 1
def get_order_details(existing=False): print("===================") employee_name = input("Enter your name: ") employee = get_employee_by_first_name(employee_name) # store_id = input("Enter your store id") if existing: customer_id = input_int_validation("Enter customer_id: ") #new_order = Order(customer_id=customer_id, employee_id=employee_id, store_id=store_id) #return new_order else: date = datetime.utcnow() return { 'employee_id': employee._id, 'store_id': employee.store_id, 'order_date': datetime(year=date.year, month=date.month, day=date.day) }
def search_store(name=None): if name is not None: print(f"Where should {name} work?".center(30, " ")) print("=" * 30) else: print(f"Choose a store".center(30, " ")) print("=" * 30) stores = sc.get_all_stores() print("\n".join(f"{i}. {store.store_address} in {store.store_name}" for i, store in enumerate(stores, 1))) selection = input_int_validation("Enter number: ") return stores[selection - 1]
def get_product_in_order(): order_details = [] # print(f"Products".center(45, '#')) # products = get_all_products() # for product in products: # print(f"Id: ".ljust(30), end='|') # print(f"{product.spare_part_id}") # print(f"Description: ".ljust(30), end='|') # print(f"{product.description}") # print(f"".center(45, '-')) # print() while True: print("What product nr? Enter 'done' to complete the order.") spare_part_id = input("Enter product id: ") if spare_part_id == "done": break quantity = input_int_validation("How many of said product: ") line = {'spare_part_id': ObjectId(spare_part_id), 'quantity': quantity} order_details.append(line) return order_details
def select_employee_menu(): while True: print("Select employee menu".center(30, " ")) print("=" * 30) print("Search employee by:") print("1. First name") print("2. Store") print("0. Exit") # ----MySQL---- # selection = input_int_validation("Enter employee ID") selection = input_int_validation("Menu selection") if selection == 0: break # ----MySQL---- # employee = ec.get_employee_by_id(selection) if selection == 1: selection = input("Enter employee first name: ") employee = ec.get_employee_by_first_name(selection) if employee is not None: employee_edit_menu(employee) else: print( f"There's no one named {selection} working in our stores") continue if selection == 2: employee = find_employee_by_store() employee_edit_menu(employee) else: print(f"\nMenu selection {selection} is not a valid option!\n")