def update(table, id_):
    """
    Updates specified record in the table. Ask users for new data.

    Args:
        table (list): list in which record should be updated
        id_ (str): id of a record to update

    Returns:
        list: table with updated record
    """

    # your code

    key = common.check_for_key(id_, table)
    if key == None:
        ui.print_error_message('Key does not exist')
    else:
        return_inputs = ui.get_inputs(['Name', 'Mail', 'Subscribed'],
                                      'Enter New Values')
        modif_index = key

        table[modif_index][NAME] = return_inputs[FIRST_PROP]
        table[modif_index][MAIL] = return_inputs[SECOND_PROP]
        table[modif_index][SUBSCRIBED] = return_inputs[THIRD_PROP]
        data_manager.write_table_to_file('crm/customers.csv', table)

    return table
def update(table, id_):
    """
    Updates specified record in the table. Ask users for new data.

    Args:
        table (list): list in which record should be updated
        id_ (str): id of a record to update

    Returns:
        list: table with updated record
    """

    key = common.check_for_key(id_, table)
    if key == None:
        ui.print_error_message('Key does not exist')
    else:
        return_inputs = ui.get_inputs(
            ['Title', 'Price', 'Year', 'Month', 'Day', 'Key From Customers'],
            "Please enter a new record.")
        modif_index = key

        table[modif_index][TITLE] = return_inputs[FIRST_PROP]
        table[modif_index][PRICE] = return_inputs[SECOND_PROP]
        table[modif_index][MONTH] = return_inputs[FOURTH_PROP]
        table[modif_index][DAY] = return_inputs[FIFTH_PROP]
        table[modif_index][YEAR] = return_inputs[THIRD_PROP]
        table[modif_index][CUSTOMER_ID] = return_inputs[SIXTH_PROP]
        data_manager.write_table_to_file('sales/sales.csv', table)

    return table
def remove(table, id_):
    """
    Remove a record with a given id from the table.

    Args:
        table (list): table to remove a record from
        id_ (str): id of a record to be removed

    Returns:
        list: Table without specified record.
    """

    # your code
    key = common.check_for_key(id_, table)

    if key == None:
        ui.print_error_message('Key does not exist')
    else:
        table.pop(key)
        data_manager.write_table_to_file('crm/customers.csv', table)

    #print(table)
    return table
def get_inputs(list_labels, title):
    """
    Gets list of inputs from the user.
    Sample call:
        get_inputs(["Name","Surname","Age"],"Please provide your personal information")
    Sample display:
        Please provide your personal information
        Name <user_input_1>
        Surname <user_input_2>
        Age <user_input_3>

    Args:
        list_labels (list): labels of inputs
        title (string): title of the "input section"

    Returns:
        list: List of data given by the user. Sample return:
            [<user_input_1>, <user_input_2>, <user_input_3>]
    """
    inputs = []
    # your code

    months = {1:31, 2:28, 3:31, 4:30, 5:31, 6:30, 7:31, 8:31, 9:30, 10:31, 11:30, 12:31}
    if len(title) > 0:
        print(title)
    for elem in list_labels:

        if elem in CHECK_NUMS:
            possible_int = input('{} '.format(elem))
            while common.check_empty(possible_int) == False or common.check_age(possible_int) == False:
                print('value {} for {} is not a valid number type.'.format(possible_int, elem.lower()))
                possible_int = input('{} '.format(elem))
            
            if elem == 'Year':
                if common.check_leap(int(possible_int)) == True:
                    months[2] = 29
                    print('{Year} is a Leap Year, February will have 29 days.'.format(Year = possible_int))
            inputs.append(possible_int)   
        
        elif elem == 'Month':
            possible_int = input('{} '.format(elem))
            while common.check_month(possible_int) == False:
                possible_int = input('{} '.format(elem))
            inputs.append(possible_int)    
        
        elif elem == 'Day': 
            possible_int = input('{} '.format(elem))
            while common.check_day(possible_int, months, int(inputs[-1])) == False:
                possible_int = input('{} '.format(elem))
            inputs.append(possible_int)

        elif elem in OTHER_KEYS.keys():
            possible_string = input('{} '.format(elem))
            while common.check_empty(possible_string) == False or common.check_for_key(possible_string, OTHER_KEYS[elem]) == None:
                print_error_message('Invalid Key')
                possible_string = input('{} '.format(elem))
            inputs.append(possible_string)    

        elif elem in CHECK_EMAIL:
            possible_mail = input('{} '.format(elem))
            while common.check_empty(possible_mail) == False or common.check_email(possible_mail) == False:
                print_error_message('Not a valid mail')
                possible_mail = input('{} '.format(elem))
            inputs.append(possible_mail)

        elif elem in BINARY_FIELDS:
            possible_binary = input('{} '.format(elem))
            while common.check_empty(possible_binary) == False or common.check_binary(possible_binary) == False:
                print_error_message('Not a valid binary field')
                possible_binary = input('{} '.format(elem))
            inputs.append(possible_binary)

        else:
            possible_string = input('{} '.format(elem))
            while common.check_empty(possible_string) == False:
                print_error_message('This string can\'t be empty')
                possible_string = input('{} '.format(elem))
            inputs.append(possible_string)
    return inputs