def edit_client_info():
    os.system('clear')

    client_name, cilent_exists, client_index = fr_functions.lookup(
        "client's", cfg.CLIENT_LIST)

    print("\tCurrent client information:")
    print("\t" + item.first_name + " " + item.last_name)
    print("\t" + item.street)
    print("\t" + item.city)
    print("\t" + item.country)
    print("\t" + item.zipcode)
    print("\t" + item.email)
    print("\t" + item.phone)

    new_email = input("\n\tEnter client e-mail:\n >> ").lower()
    new_phone = input("\n\tEnter client phone (###-###-####):\n >> ")
    new_street = input("\n\tEnter client's street address:\n >>")
    new_city = input("\n\tEnter client's city and province:\n >>").title()
    new_country = input("\n\tEnter client's country:\n >>")
    new_zipcode = input("\n\tEnter client's postal code:\n >>")

    fr_functions.alert("Warning: you cannot undo this change.")
    if fr_functions.verification() == 'y':
        cfg.CLIENT_LIST[client_index].email = new_email
        cfg.CLIENT_LIST[client_index].phone = new_phone
        cfg.CLIENT_LIST[client_index].street = new_street
        cfg.CLIENT_LIST[client_index].city = new_city
        cfg.CLIENT_LIST[client_index].country = new_country
        cfg.CLIENT_LIST[client_index].zip_code = new_zipcode

    menu_main.execute_menu('c')
def edit_project(name, item_index):
    """ Adds Session class to the projects that cantains information on the
    various sessions that happened (ie. Recording session on a date or whatnot)
    """
    os.system("clear")

    print('\nPlease choose a project to add a session to:\n')
    print("      Project Name")
    print("    " + "=" * 50)
    count = 1
    for item in cfg.CLIENT_LIST[item_index].projects:
        print("[%s] " % count + item.name.ljust(50).title())
        count += 1
    print("\n")

    project_choice = fr_functions.check_if_number() - 1
    session_date = time.strftime("%d/%m/%Y")
    print ("How long was the session length?")
    session_length = fr_functions.check_if_number()
    while True:
        service_name, service_exists, service_index = fr_functions.lookup(
            "service", cfg.SERVICES)
        if service_exists is True:
            cost = cfg.SERVICES["%s" % service_name.title()] * session_length
            cfg.CLIENT_LIST[item_index].projects[
                project_choice].sessions.append(fr_classes.Sessions(
                    session_date, service_name, session_length, cost,
                    cfg.SERVICES["%s" % service_name.title()]))
            break
        else:
            fr_functions.alert("Service does not exist.")

    fr_functions.save_database()
    menu_main.projects_menu(name, item_index)
def view_invoice():
    os.system('clear')

    print("\n\nTo find specific invoices, please enter client's full name:")
    name = input(" >> ").title()
    temp_list = []
    for item in cfg.INVOICES:
        if name == item.customer_info[0]:
            temp_list.append(item)
        elif name != item.customer_info[0] and item is cfg.INVOICES[-1] and (
                not temp_list):
            fr_functions.alert("No such customer exists.")
            menu_main.invoice_menu()

    os.system("clear")
    print("\n\n\tShowing past invoices for:")
    print("\t" + temp_list[1].customer_info[0])
    print("\t" + temp_list[1].customer_info[2])
    print("\t" + temp_list[1].customer_info[3])
    print("\t" + temp_list[1].customer_info[4])
    print("\t" + temp_list[1].customer_info[5])

    print("\n\n" + "Invoice No.".rjust(15) + "  Invoice Date")
    print("=" * 40)
    count = 1
    for item in temp_list:
        print(str(count).ljust(4) + str(
              item.invoice_number).rjust(11).zfill(5) + "  " +
              item.invoice_date)
        count += 1

    print("\nWhich invoice would you like to view:")
    view_invoice = fr_functions.check_if_number() - 1
    current_invoice = temp_list[view_invoice]
    fr_functions.write_to_csv(fr_functions.unpack_invoice_information(
                              current_invoice))
    fr_generate_invoice.make_invoice()
    menu_main.main_menu()