{% extends "bee_django_crm/base.html" %}
{% load bee_django_crm_filter %}

{% block content %}
    {% include 'bee_django_crm/logo.html' %}
    {% include 'bee_django_crm/nav.html' %}
    <div class="text-center"><h3>
        用户合同列表
    </h3>
    </div>
    {% if not preuser %}
        {% include 'bee_django_crm/preuser/preuser_contract_search.html' %}
    {% endif %}

    <div class="text-right">
        {% if preuser %}
            <a href="{% url 'bee_django_crm:preuser_contract_add' preuser.id %}"
               class="btn btn-default"
                    >创建新合同</a>
        {% endif %}
    </div>
    <div>共{{ paginator.count }}条</div>
    <table class="table">
        <thead>
        <tr>
            <th></th>
            <th>学生</th>
            <th>合同名称</th>
            <th>应缴金额</th>
            <th>创建时间</th>
            <th>是否签署协议</th>
            <th></th>
            <th></th>

        </tr>
        </thead>
        <tbody>
        {% for user_contract in preuser_contract_list %}
            <tr>
                <td>{{ forloop.counter }}</td>
                <td>{{ user_contract.preuser.name }}</td>
                <td>{{ user_contract.contract.name }}</td>
                <td>{{ user_contract.price }}</td>
                <td>{{ user_contract.created_at }}</td>
                <td>{% if user_contract.is_user_agree %}
                    已签协议
                {% else %}
                    <a href="{% url 'bee_django_crm:preuser_contract_agreement' user_contract.id %}">协议链接</a>
                {% endif %}</td>
                <td><a href="{% url 'bee_django_crm:preuser_contract_detail' user_contract.id %}">详情</a></td>
                <td>


                </td>
            </tr>

        {% endfor %}
        </tbody>
    </table>
    {% include 'bee_django_crm/paginator.html' %}
{% endblock %}
{% block scripts %}
    <script>
        function click_check(_this) {
            if (!confirm('确认要执行这个操作？')) {
                return false;
            }
            var url = $(_this).attr('data-confirm');
            $.post(url).done(function (data) {
                alert('审核成功!');

                location.href = data.url;
            });
        }
    </script>
{% endblock %}