{% extends "base.html" %}
{% load staticfiles %}


{% block staticcss %}

{% endblock %}

{% block staticjs %}
<script>
    $(document).ready(function () {
        $('#dataTable').DataTable({
            responsive: true,
            "language": {

                "sProcessing": "处理中...",
                "sLengthMenu": "显示 _MENU_ 项结果",
                "sZeroRecords": "没有匹配结果",
                "sInfo": "显示第 _START_ 至 _END_ 项结果，共 _TOTAL_ 项",
                "sInfoEmpty": "显示第 0 至 0 项结果，共 0 项",
                "sInfoFiltered": "(由 _MAX_ 项结果过滤)",
                "sInfoPostFix": "",
                "sSearch": "搜索:",
                "sUrl": "",
                "sEmptyTable": "表中数据为空",
                "sLoadingRecords": "载入中...",
                "sInfoThousands": ",",
                "oPaginate": {
                    "sFirst": "首页",
                    "sPrevious": "上页",
                    "sNext": "下页",
                    "sLast": "末页"
                },
                "oAria": {
                    "sSortAscending": ": 以升序排列此列",
                    "sSortDescending": ": 以降序排列此列"
                }
            }
        });
    });
</script>
{% endblock %}

{% block content %}


<!-- Page Content -->
<div id="page-wrapper">


    <div class="container-fluid">
        <div class="d-sm-flex align-items-center justify-content-between mb-4">
            <h1 class="h3 mb-0 text-gray-800">项目任务</h1>
        </div>
    </div>
    <!-- /.container-fluid -->

    {% if messages %}
    <ul class="messages">
        {% for message in messages %}
        <div {% if message.tags %} class="alert alert-{{ message.tags }}" {% endif %}><strong>{{ message }}</strong>
        </div>
        {% endfor %}
    </ul>
    {% endif %}

    <!-- /.row -->
    <div class="card shadow mb-4">
        <div class="card-header py-3 d-flex flex-row align-items-center justify-content-between">
            <h6 class="m-0 font-weight-bold text-primary">项目列表</h6>
            <div class="dropdown no-arrow">
                <a class="dropdown-toggle" href="#" role="button" id="dropdownMenuLink" data-toggle="dropdown"
                    aria-haspopup="true" aria-expanded="false">
                    <i class="fas fa-ellipsis-v fa-sm fa-fw text-gray-400"></i>
                </a>
                <div class="dropdown-menu dropdown-menu-right shadow animated--fade-in"
                    aria-labelledby="dropdownMenuLink">
                    <a class="dropdown-item" href="{% url 'addproject' %}">
                        添加项目
                    </a>
                    {% ifequal stat 'list'%}
                    <a class="dropdown-item" href="{% url 'projectlist' 'done' %}">已完成项目</a>
                    {% else %}
                    <a class="dropdown-item" href="{% url 'projectlist' 'list' %}">
                        未完成项目
                    </a>
                    {% endifequal %}
                </div>
            </div>
        </div>

        <div class="card-body">
            <!--表单报错显示-->
            {% if form.errors %}

            {% for field, error in form.errors.items %}
            <div class="alert alert-error">
                {{ field }} <code>{{ error }}</code>
            </div>
            {% endfor %}


            {% endif %}
            <div class="table-responsive">
                <table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
                    <thead>
                        <tr>
                            <th>ID</th>
                            <th>项目名称</th>
                            <th>创建日期</th>
                            <th>创建人</th>
                            <th>项目参与人</th>
                            <th>子项目</th>
                            <th>状态</th>
                            <th>操作</th>
                        </tr>
                    </thead>
                    <tfoot>
                        <tr>
                            <th>ID</th>
                            <th>项目名称</th>
                            <th>创建日期</th>
                            <th>创建人</th>
                            <th>项目参与人</th>
                            <th>子项目</th>
                            <th>状态</th>
                            <th>操作</th>
                        </tr>
                    </tfoot>
                    <tbody>
                        {% for list in project %}
                        <tr class="odd gradeX">
                            <td>{{ forloop.counter }}
                                {% if list.overdue_status %}
                                <i class="fas fa-exclamation-triangle"></i>

                                {% endif %}
                            </td>
                            <td>{{ list.name }}</td>
                            <td>{{ list.created_date }}</td>
                            <td>{{ list.created_by }}</td>
                            <td>{% for u in list.assigned_to.all %}{{ u.username }} {% endfor %}</td>
                            <td>{{ list.getsubnum }}</td>
                            <td>{{ list.get_stat_display }}</td>
                            
                            <td>
                                    <!-- <a class="btn btn-outline btn-primary" href="{% url 'gantt' list.id %}">甘特图</a> -->

                                    <a class="btn btn-outline btn-primary"
                                        href="{% url 'subprojectlist' list.id %}">查看</a>

                                    <a class="btn btn-outline btn-danger"
                                        href="{% url 'editproject' list.id %}">编辑</a>

                            </td>
                        </tr>
                        {% endfor %}

                    </tbody>
                </table>
               
            </div>
        </div>
    </div>
    
</div>


{% endblock %}