{% load custom_tags_and_filters %}
<div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-label="Modal close button">&times;</button>
    <h4 id="modal-description-label" class="modal-title">
        {% if error_message %}
            Error trying
        {% else %}
            You are about
        {% endif %}
        to login to the {{ area }}
    </h4>
</div>
<div class="modal-body">
    <input type="hidden" id="dialog_cancelled" value="true">
    {% if error_message %}<div class="alert alert-danger">{{ error_message }}</div>{% endif %}
    {% if not error_message %}
        <form id="additional_event_parameters" onsubmit="return false">
            <input type="hidden" name="area" value="{{ area.id }}">
            <input type="hidden" id="project_id" name="project_id">
            <div class="form-group">
                {% if projects|length == 1 %}
                    You only have one active project. Area access will be billed to: {{ projects.0 }}
                    <input type="hidden" name="project" value="{{ projects.0.id }}">
                {% else %}
                    <p>Charge area access to which project?</p>
                    {% for p in projects %}
                        <div class="radio">
                            <label>
                                <input type="radio" name="project" value="{{ p.id }}" required>
                                {% project_selection_display p %}
                            </label>
                        </div>
                    {% endfor %}
                {% endif %}
            </div>
            <div class="form-group">
                {% with project_id=project.id|default_if_none:"" %}
                    {% button type="save" submit=False icon="glyphicon-log-in" dismiss="modal" onclick="$('#project_id').val("|concat:project_id|concat:"); $('#dialog_cancelled').val(false)" value="Log in" %}
                {% endwith %}
            </div>
        </form>
    {% else %}
        <div class="form-group text-center">
            <button class="btn btn-warning" data-dismiss="modal">Ok</button>
        </div>
    {% endif %}
</div>
