{% 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>
    <div class="text-right">
        <a class="btn btn-default" href="{% url 'bee_django_crm:contract_add' %}">添加合同</a>
    </div>
    <div>共{{ paginator.count }}个</div>
    <table class="table">
        <thead>
        <tr>
            <th></th>
            <th>名称</th>
            <th>期限</th>
            <th>价格</th>

        </tr>
        </thead>
        <tbody>
        {% for contract in contract_list %}
            <tr>
                <td>{{ forloop.counter }}</td>
                <td>{{ contract.name }}</td>
                <td>{{ contract.get_contract_days }}</td>
                <td>{{ contract.price }}元</td>
                <td>
                                    <a href="{% url 'bee_django_crm:contract_detail' contract.id %}  ">详情</a>  <a href="{% url 'bee_django_crm:contract_update_agreement' contract.id %}  ">修改协议</a>
                    {#                    <a href="#" id="delete_{{ contract.id }}"#}
                    {#                       data-confirm="{% url "bee_django_crm:contract_delete" contract.id %}"#}
                    {#                       onclick="click_del(this)">删除</a>#}
                </td>
            </tr>

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