{% extends "base.html" %}


{% block title %}任务列表{% endblock %}

{% 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>
    {% if messages %}
    <ul class="messages">
        {% for message in messages %}
        <li {% if message.tags %} class="alert-{{ message.tags }}" {% endif %}>{{ message }}</li>
        {% endfor %}
    </ul>
    {% endif %}
    <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" data-toggle="modal" data-target="#myModal">
                        添加任务
                    </a>



                </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>选择</th>
                            <th>ID</th>
                            <th>笔试项目</th>
                            <th>考试地址</th>
                            <th>是否可以报名</th>
                            <th>操作</th>
                        </tr>
                    </thead>
                    <tfoot>
                        <tr>
                            <th>选择</th>
                            <th>ID</th>
                            <th>笔试项目</th>
                            <th>考试地址</th>
                            <th>是否可以报名</th>
                            <th>操作</th>

                        </tr>
                    </tfoot>
                    <tbody>
                        {% for list in bsproject %}
                        <tr class="odd gradeX">

                            <td><input class="checkbox" type="checkbox" value="{{ list.id }}" name="mark_done"></td>
                            <td>{{ forloop.counter }}
                            </td>
                            <td>{{ list.name}}</td>
                            <td>{{ list.link }}</td>
                            <td>{{ list.able }}</td>
                            <td>
                                <form action='./dcbsproject?id={{list.id}}' method="POST">
                                    {% csrf_token %}                          
                                    <input type='submit' class="btn btn-primary" value="导出">
                                </form>
                                <a class="btn btn-outline btn-info" href="./ebsproject/{{list.id}}">编辑</a>
                                <a class="btn btn-outline btn-danger" href="#" data-href="#" data-toggle="modal"
                                    data-target="#confirm-delete">删除</a>
                            </td>
                        </tr>
                        {% endfor %}

                    </tbody>
                </table>

            </div>
        </div>
    </div>

</div>

<!--表单报错显示-->
{% if form.errors %}

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


{% endif %}

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel">新任务</h4>
            </div>
            <form role="form" onsubmit="return dosubmit()" method="post">
                {% csrf_token %}
                <div class="modal-body">

                    {% for hidden in form.hidden_fields %}
                    {{ hidden }}
                    {% endfor %}
                    {% for field in form.visible_fields %}

                    <div class="form-group">
                        <label class="control-label">{{ field.label_tag }}</label>
                        <div class="controls">

                            {{ field.errors }}{{ field }}{{ field.help_text }}
                        </div>
                    </div>
                    {% endfor %}

                </div>
                <div class="modal-footer">
                    <button type="reset" class="btn btn-default" data-dismiss="modal">重设</button>
                    <button type="submit" class="btn btn-primary" name="addbsproject">保存</button>
                </div>
            </form>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>
<!-- /.modal -->
<form role="form" onsubmit="return dosubmit()" method="post">
    {% csrf_token %}
    <div class="modal fade" id="myExport" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">

                <div class="modal-body">
                    确认导出记录吗？
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    <button class="btn btn-primary" type="submit" name="export">导出</button>
                </div>
            </div>
        </div>
    </div>
</form>

{% endblock %}