{% extends "bee_django_crm/base.html" %}
{% load static %}
{% block content %}
    {% include 'bee_django_crm/logo.html' %}
    {% include 'bee_django_crm/nav.html' %}
    <div style="margin: 20px;">
        <form method="post">
            {% csrf_token %}

                    {{ form.as_ul }}
{#            {{ preuser_form.as_ul }}#}

            <input type="submit" value="提交"/>
        </form>
    </div>
{% endblock %}


{% block scripts %}
    <script>
        $(document).ready(function () {
            //时间
            $.datetimepicker.setLocale('ch');
            var $birthday = $("#id_birthday");
            $birthday.datetimepicker({
                format: 'Y-m-d',
                timepicker: false,
                scrollMonth: false,
                scrollTime: false,
                scrollInput: false
            });
            {#            $("#id_source").prepend("<option value='{{ source.id }}'  selected = 'selected'>当前：{{ source.name }}</option>");   //为Select插入一个Option(第一个位置)#}

        });

        function get_referral_user_name(i) {
            var $referral_user_name = $("#referral_user_name"+i);
            $referral_user_name.text("");
            var id_referral_user_id = $("#id_referral_user_id"+i).val();
            if (!id_referral_user_id) {
                $referral_user_name.text("无");
                return;
            }
            $.getJSON("{% url 'bee_django_crm:get_name_with_user' %}?id=" + id_referral_user_id, function (res) {
                if (res.name) {
                    $referral_user_name.text(res.name);
                } else {
                    $referral_user_name.text("无");
                }
            });
        }
    </script>
{% endblock %}