{% extends 'base.html' %}
{% load static %}
{% load bootstrap %}
{% block custom_head_css_js %}
    <link href="{% static "css/plugins/chosen/chosen.css" %}" rel="stylesheet">
    <link href="{% static "css/plugins/datepicker/datepicker3.css" %}" rel="stylesheet">
    <script src="{% static "js/plugins/chosen/chosen.jquery.min.js" %}"></script>
{% endblock %}

{% block content %}
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>填写用户信息</h5>
                        <div class="ibox-tools">
                            <a class="collapse-link">
                                <i class="fa fa-chevron-up"></i>
                            </a>
                            <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                                <i class="fa fa-wrench"></i>
                            </a>
                            <a class="close-link">
                                <i class="fa fa-times"></i>
                            </a>
                        </div>
                    </div>
                    <div class="ibox-content">
                        <form method="post" id="userForm" class="form-horizontal" action="" enctype="multipart/form-data">
                            {% csrf_token %}
                            <h3>账户</h3>
                            {% block username %} {% endblock %}
                            {{ form.name|bootstrap_horizontal }}
                            {{ form.email|bootstrap_horizontal }}
                            {{ form.groups|bootstrap_horizontal }}

                            <div class="hr-line-dashed"></div>
                            {% block password %} {% endblock %}

                            <div class="hr-line-dashed"></div>
                            <h3>角色安全</h3>
                            {{ form.role|bootstrap_horizontal }}
                            <div class="form-group" id="date_5">
                                <label for="{{ form.date_expired.id_for_label }}" class="col-sm-2 control-label">{{ form.date_expired.label }}</label>
                                <div class="col-sm-9">
                                    <div class="input-group date">
                                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                                        <input id="{{ form.date_expired.id_for_label }}" name="{{ form.date_expired.html_name }}" type="text" class="form-control" value="{{ form.date_expired.value|date:'m/d/Y' }}">
                                    </div>
                                </div>
                             </div>
                            <div class="form-group">
                                <label for="{{ form.enable_otp.id_for_label }}" class="col-sm-2 control-label">二次验证</label>
                                <div class="col-sm-8">
                                    {{ form.enable_otp }}
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <h3>信息</h3>
                            {{ form.phone|bootstrap_horizontal }}
                            {{ form.wechat|bootstrap_horizontal }}
                            {{ form.comment|bootstrap_horizontal }}
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <div class="col-sm-4 col-sm-offset-2">
                                    <button class="btn btn-white" type="reset">取消</button>
                                    <button id="submit_button" class="btn btn-primary" type="submit">确认保存</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
{% endblock %}
{% block custom_foot_js %}
    <script src="{% static 'js/plugins/datapicker/bootstrap-datepicker.js' %}"></script>
    <script>
        $(document).ready(function () {
            var config = {
                '.chosen-select'           : {},
                '.chosen-select-deselect'  : {allow_single_deselect:true},
                '.chosen-select-no-single' : {disable_search_threshold:10},
                '.chosen-select-no-results': {no_results_text:'Oops, nothing found!'},
                '.chosen-select-width'     : {width:"95%"}
            };
            for (var selector in config) {
                $(selector).chosen(config[selector]);
            }

            $('.input-group.date').datepicker({
                todayBtn: "linked",
                keyboardNavigation: false,
                forceParse: false,
                calendarWeeks: true,
                autoclose: true
            });
        })
    </script>
{% endblock %}