def edit_remove_menu(chosen_employee): while True: print(f"Vad vill du göra med {chosen_employee}") print("1. Redigera") print("2. Ta bort") print("3. Avbryt") selected = int_input("> ") if selected == 1: edit_employee(chosen_employee) elif selected == 2: remove_employee(chosen_employee) break elif selected == 3: break else: print("Felaktig inmatning")
def remove_employee(chosen_employee): while True: print("----------------") print("TA BORT ANSTÄLLD") print(f"Är du säker på att du vill ta bort {chosen_employee}") print("1. Ja") print("2. Nej") confirm = int_input("> ") if confirm == 1: removed_string = ec.remove_employee(chosen_employee) print(removed_string) break elif confirm == 2: print("Anställd har inte tagits bort") break else: print("Felaktig inmatning")
def customer_management_menu(): while True: print(" KUNDHANTERING ") print("----------------------") print("1. Sök upp befintlig kund") print("2. Lägg till ny kund") print("3. Huvudmeny") selected = int_input("> ") if selected == 1: find_customer_menu() elif selected == 2: add_new_customer() elif selected == 3: break else: print("Du har gjort ett ogiltigt val. Försök igen.")
def main_menu(): while True: print(" HUVUDMENY ") print("----------------------") print("1. Admin") print("2. Kundhantering") print("3. Avsluta") selected = int_input("> ") if selected == 1: admin_menu() elif selected == 2: customer_management_menu() elif selected == 3: break else: print("Du har gjort ett ogiltigt val. Försök igen.")
def employees_menu(): while True: print(" ANSTÄLLDA ") print("-----------------") print("1. Redigera/ta bort") print("2. Lägg till") print("3. Gå tillbaka till adminmeny") selected = int_input("> ") if selected == 1: find_employee() elif selected == 2: add_employee() elif selected == 3: break else: print("Felaktig inmatning")
def edit_employee(chosen_employee): while True: print("------------------") print(f"REDIGERA ANSTÄLLD") print(f"1. Namn: {chosen_employee.name}") print(f"2. Butik: {chosen_employee.store}") print(f"3. Telefonnummer: {chosen_employee.phone}") print(f"4. Email: {chosen_employee.email}") print(f"5. Jobtitel: {chosen_employee.job_title}") print(f"6. Avbryt") print(f"Vilken rad vill du redigera?") selected = int_input("> ") if selected == 1: chosen_employee.name = input("Ange nytt namn: ") changed_string = ec.save_changes(chosen_employee) print(changed_string) elif selected == 2: chosen_employee.store = input("Ange ny butik (Ange butikens id): ") changed_string = ec.save_changes(chosen_employee) print(changed_string) elif selected == 3: chosen_employee.phone = input("Ange nytt telefonnummer: ") changed_string = ec.save_changes(chosen_employee) print(changed_string) elif selected == 4: chosen_employee.email = input("Ange ny mail: ") changed_string = ec.save_changes(chosen_employee) print(changed_string) elif selected == 5: chosen_employee.job_title = input("Ange ny jobtitel: ") changed_string = ec.save_changes(chosen_employee) print(changed_string) elif selected == 6: break else: print("Felaktig inmatning")
def find_employee(): while True: search = input("Sök: ") matching_employees = ec.find_employees(search) if len(matching_employees) == 0: print("Hittade inga anställda som uppfyller sökkraven") else: print("Matchande sökningar: ") for i, employee in enumerate(matching_employees): print(f"{i + 1}: {employee}") while True: selected = int_input("> ") if 1 <= selected <= len(matching_employees): chosen_employee = matching_employees[selected - 1] break else: print("Felaktig inmatning") edit_remove_menu(chosen_employee) break
def search_and_choose(): while True: keyword = input("Sök butik efter namn: ") stores = cs.find_store(keyword) if len(stores) == 0: print("Det finns ingen butik som upfyller sökkraven.") else: print("Matchande sökningar:") for i, store in enumerate(stores, start=1): print(f"{i}. {store}") while True: choice = int_input("Vilken butik vill du visa? ") if 1 <= choice < len(stores): store = stores[choice] break else: print("Du har gjort ett ogiltigt val. Försök igen.") edit_remove_menu(store) break
def car_model_menu(): while True: print("BILMODELLER".rjust(13)) print("-----------------") print("1. Redigera/ta bort") print("2. Lägg till") print("3. Huvudmeny") selected = int_input("> ") if selected == 1: search = input("Sök: ") find_car_model(search) elif selected == 2: print("Ange information om den bilmodell du vill lägga till") c_manufacturer = input("Tillverkare: ") c_model = input("Modell: ") c_year_model = input("Årsmodell: ") c = (c_manufacturer, c_model, c_year_model) add_car_model(c) elif selected == 3: break else: print("Du har gjort ett ogiltigt val. Försök igen.")