{% load i18n %}
{% load tj_filters %}


<script type="text/javascript" src='/static/js/tinymce/tinymce.min.js'></script> 
<script type="text/javascript" src='/static/js/tinymce/plugins/table/plugin.min.js'></script>
<script type="text/javascript" src='/static/js/tinymce/plugins/link/plugin.min.js'></script> 

<link href= "/static/js/select2-4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
<script src="/static/js/select2-4.1.0-rc.0/dist/js/select2.min.js"></script>


<script type="text/javascript">

    function checkAgentName(id) {
        var name = $("#id_name").val()
        var url
        url = "obj/yzgj/check/externalcode/agent_name/19267/" +id+"/"+ name
        $.ajax({
            url: url,
            type: "GET",
            datatype: "json",
            success: function (data) {
                if (data.flag) {
                    alert("该加盟名称已存在，请重新输入。")
                    $("#id_name").val("")
                }
            },
            error: function () {
                alert("网络波动，请稍后再试。")
            }
        })


    }
    
    

    function checkCode(id) {
        var code = $("#id_external_code").val()
        var url
        url = "obj/yzgj/check/externalcode/agent_code/19267/" +id+"/"+ code

        if (code != "") {
            $.ajax({
                url: url,
                type: "GET",
                datatype: "json",
                success: function (data) {
                    if (data.flag) {
                        alert("该编码已存在，请重新输入。")
                        $("#id_external_code").val("")
                    }
                },
                error: function () {
                    alert("网络波动，请稍后再试。")
                }
            })
        }

    }

    $(document).ready(function(){
        {% block js %}    
            $("#obj_form input,#obj_form select").addClass("form-control");
            {% if is_saved %}  
                $('.btn').show();
                toastr.success("{% trans '数据保存成功!' %}",
                    "{% trans '消息提示' %}",{timeOut: 800, positionClass: "toast-center-center"}
                ); 
            {% endif %}     


            $(".btn-obj-add").click(function () { 
                event.preventDefault();
                $.RefreshContent($(this).attr('href'));        
            });

        {% endblock %}
    });
</script>


<div > 
    {% block subtitle %}
    <ol class="breadcrumb">
        <li>{% block subtitle-1 %}{% endblock %}</li>
        <li>{% block subtitle-2 %}{% endblock %}</li>
       

        {% if is_saved %}
            <a type="button" class='btn btn-obj-add l-a create-btn pull-right'  href="{{request.path}}">
                <span class='glyphicon glyphicon-plus' style='padding-right:5px;'></span>
                {% trans '新建' %}
            </a>
        {% endif %}
    </ol>
    {% endblock %}
</div>



   
<div class="row">
<div class="col-md-12 col-sm-12 col-xs-12">
<div id="obj_form" class="container" >    
    <form role="form" method='POST' enctype="multipart/form-data" class="form-horizontal"> {% csrf_token %}
    <div class="x_panel">
    <br />
    <div class="edit_panel">
    {% block form_content %}
        {% if messages %}
            {% for message in messages %}
                <div class="alert {% if message.tags %} alert-{{ message.tags }}{% endif %}">{{ message|safe }}</div>
            {% endfor %}
        {% endif %}
        {% if form.errors %}
            <div class="alert alert-error">
                <h4>{% trans '数据输入有错误,请先改正以下错误:' %}</h4>
                <ul>
                    {% for field in form %}
                        {% if field.errors %}
                            {% for error in field.errors %}
                                <li class="error">{{ field.label}}: {{ error|escape }}</li>
                            {% endfor %}
                        {% endif %}
                    {% endfor %}
                </ul>
                {% if form.non_field_errors %}
                    {{ form.non_field_errors }}
                {% endif %}
            </div>
        {% endif %}
        {% for hidden_field in form.hidden_fields %}
            {{ hidden_field }}
        {% endfor %}       
    {% endblock %}
    </div>
    </div>  

    <div class="clearfix"></div>
    {% block extra %}{% endblock %}
    {% block fmset %}{% endblock %}
    </form>
</div>
</div>
</div>
