{% spaceless %}

{% load i18n %}

<form method="post" id="{{ form_id }}">
    {% csrf_token %}

    <div class="form-group">
        <label for="{{ form_id }}_full_name">{% trans "Name" %}:</label>
        <input name="full_name" class="form-control" required id="{{ form_id }}_full_name" value="{{ form.full_name.value|default_if_none:'' }}" maxlength="100">
    </div>

    <div class="form-group">
        <label for="{{ form_id }}_address_1">{% trans "Address" %}:</label>
        <input name="address_1" class="form-control" required id="{{ form_id }}_address_1" value="{{ form.address_1.value|default_if_none:'' }}" maxlength="100">
    </div>

    <div class="form-group">
        <input name="address_2" class="form-control"{% if form.fields.address_2.required %} required{% endif %} id="{{ form_id }}_address_2" value="{{ form.address_2.value|default_if_none:'' }}" maxlength="100">
    </div>

    {% if hide_address_3 is not True %}
        <div class="form-group">
            <input name="address_3" class="form-control"{% if form.fields.address_3.required %} required{% endif %} id="{{ form_id }}_address_3" value="{{ form.address_3.value|default_if_none:'' }}" maxlength="100">
        </div>
    {% endif %}

    {% if hide_address_4 is not True %}
        <div class="form-group">
            <input name="address_4" class="form-control"{% if form.fields.address_4.required %} required{% endif %} id="{{ form_id }}_address_4" value="{{ form.address_4.value|default_if_none:'' }}" maxlength="100">
        </div>
    {% endif %}

    {% if hide_address_5 is not True %}
        <div class="form-group">
            <input name="address_5" class="form-control"{% if form.fields.address_5.required %} required{% endif %} id="{{ form_id }}_address_5" value="{{ form.address_5.value|default_if_none:'' }}" maxlength="100">
        </div>
    {% endif %}

    {% if hide_country_state is not True %}
        <div class="form-group{% if address_extras.current_states|length == 0 %} d-none{% endif %}">
            <label for="{{ form_id }}_state">{% trans "State" %}:</label>
            <select name="country_state" class="form-control" id="{{ form_id }}_state">
                {% for c in address_extras.current_states %}
                    <option value="{{ c.id }}"{% if c.id == form.country_state.value %} selected{% endif %}>{{ c.name }}</option>
                {% endfor %}
            </select>
        </div>
    {% endif %}

    {% if hide_country is not True %}
        <div class="form-group">Country" %}:</label>
            <select name="country" onchange="salebox.address.countryStateDropdown('{{ form_id }}')" class="form-control" id="{{ form_id }}_country">
                {% for c in address_extras.country_list %}
                    <option value="{{ c.id }}"{% if c.id == form.country.value %} selected{% endif %}>{{ c.name }}</option>
                {% endfor %}
            </select>
        </div>
    {% endif %}

    {% if hide_postcode is not True %}
        <div class="form-group">
            <label for="{{ form_id }}_postcode">{% trans "Postcode" %}:</label>
            <input name="postcode"{% if form.fields.postcode.required %} required{% endif %} class="form-control" id="{{ form_id }}_postcode" value="{{ form.postcode.value|default_if_none:'' }}" maxlength="12">
        </div>
    {% endif %}

    {% if hide_tax_id is not True %}
        <div class="form-group">
            <label for="{{ form_tax_id }}_tax_id">{% trans "Tax ID" %}:</label>
            <input name="tax_id"{% if form.fields.tax_id.required %} required{% endif %} class="form-control" id="{{ form_id }}_tax_id" value="{{ form.tax_id.value|default_if_none:'' }}" maxlength="20">
        </div>
    {% endif %}

    {% if hide_default is not True %}
        <div class="form-check">
            <input class="form-check-input" type="checkbox" checked name="default" id="{{ form_id }}_default">
            <label class="form-check-label" for="{{ form_id }}_default">{% trans "Set as default" %}</label>
        </div>
    {% endif %}

    <input type="submit"  value="{% trans "Add address" %}">
</form>

{% if address_extras.country_list|length > 1 %}
    <script>var saleboxCountryState={{ address_extras.js_states|safe }};</script>
{% endif %}

{% endspaceless %}
