{% extends request.is_ajax|yesno:'bajax.html,base.html' %}
{% load i18n bootstrap3 %}

{% block title %}{% trans 'Add abon' %}{% endblock %}

{% block breadcrumb %}
    <ol class="breadcrumb">
        <li><span class="glyphicon glyphicon-home"></span></li>
        <li><a href="{% url 'abonapp:group_list' %}">{% trans 'User groups' %}</a></li>
        <li><a href="{% url 'abonapp:people_list' group.id %}">{{ group.title }}</a></li>
        <li class="active">{% trans 'Add abon' %}</li>
    </ol>
{% endblock %}

{% block page-header %}
    {% trans 'Add abon' %}
{% endblock %}

{% block main %}
    <div class="panel panel-default">
        <div class="panel-heading">
            <h3 class="panel-title">{% trans 'Add abon' %}</h3>
        </div>
        <div class="panel-body">
            <form role="form" action="{% url 'abonapp:add_abon' group.id %}" method="post">{% csrf_token %}
                {% bootstrap_icon 'user' as ic %}
                {% bootstrap_field form.username addon_before=ic %}

                {% bootstrap_icon 'bookmark' as ic %}
                {% bootstrap_field form.fio addon_before=ic %}

                {% bootstrap_icon 'phone' as ic %}
                {% bootstrap_field form.telephone addon_before=ic %}

                {% bootstrap_icon 'grain' as ic %}
                {% bootstrap_field form.group addon_before=ic %}

                {% bootstrap_icon 'comment' as ic %}
                {% bootstrap_field form.description addon_before=ic %}

                {% bootstrap_icon 'road' as ic %}
                {% bootstrap_field form.street addon_before=ic %}

                {% bootstrap_icon 'home' as ic %}
                {% bootstrap_field form.house addon_before=ic %}

                {# password field #}
                {% bootstrap_icon 'lock' as ic %}
                {% bootstrap_button '' button_type='button' icon='eye-open' button_class='btn-default' id='passwdtoggler' size='sm' as bt %}
                {% bootstrap_field form.password form_group_class='form-group-sm' addon_after_class='input-group-btn' addon_after=bt addon_before=ic %}

                <script type="text/javascript">
                    $(function () {
                        $('#passwdtoggler').on('mousedown', function(){
                            document.getElementById("{{ form.password.id_for_label }}").type='text';
                        }).on('mouseup', function(){
                            document.getElementById("{{ form.password.id_for_label }}").type='password';
                        });
                    });
                </script>

                {# Nas server #}
                {% bootstrap_icon 'globe' as ic %}
                {% bootstrap_field form.nas addon_before=ic %}

                <div class="btn-group">
                    <button type="submit" class="btn btn-sm btn-primary">
                        <span class="glyphicon glyphicon-save"></span> {% trans 'Save' %}
                    </button>
                    <button type="reset" class="btn btn-sm btn-default">
                        <span class="glyphicon glyphicon-remove-circle"></span> {% trans 'Reset' %}
                    </button>
                </div>
            </form>
        </div>
    </div>
{% endblock %}
