{% extends "base.html" %}

{% block title %}
    参赛作品列表
{% endblock %}

{% block content %}
    <div class="section section-breadcrumbs section-breadcrumbs-backend">
        <div class="container">
            <div class="row">
                <div class="col-md-12">
                    <h1>参赛作品列表</h1>
                </div>
            </div>
        </div>
    </div>
    <div class="btn-toolbar">
        <div class="btn-group">
            {% url "pwlist" as pwlist %}
            <a class="btn btn-default {%if request.path = pwlist%} active {%endif%}" href="{{ pwlist }}"><span class="glyphicon glyphicon-list"></span>参赛作品列表</a>
            <a class="btn btn-default" type="button" data-toggle="modal" data-target="#modalDelByIpid"><span class="glyphicon glyphicon-shopping-cart"></span>按导入批号删除</a>
        </div>
    </div>

    <hr/>

    {{FilterHTML|safe}}

    <table class="table table-hover table-striped  table-bordered table-condensed">
        <tr>
            <th>作品ID</th>
            <th>标题</th>
            <th>参赛者账号</th>
            <th>参赛者姓名</th>
            <th>导入批号</th>
            <th>得票数</th>
            <th>操作</th>
        </tr>

            {% for i in lPage %}
                <tr style="font-size: 13px;">
                    <td>{{ i.uuid }}</td>
                    <td>{{ i.title }}</td>
                    <td>{{ i.author.user.username }}</td>
                    <td>{{ i.author.user.nickname  }}</td>
                    <td>{{ i.importid }}</td>
                    <td>{{ i.score }}</td>
                    <td class="host_buttom">
                        <a class="btn btn-warning btn-xs"  href={% url "pwview" i.uuid %} target="_blank">查看</a>
                        <a class="btn btn-danger btn-xs" href={% url "pwdel" i.id %} onclick="return confirm('是否确认删除？')">删除</a>
                    </td>
                </tr>
            {% endfor %}

        </table>

    {% include "common/paginator.html" %}

<div class="modal fade" id="modalDelByIpid" tabindex="-1" role="dialog" aria-labelledby="modalDelByIpidLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="modalDelByIpidLabel">按导入批号删除</h4>
      </div>
      <div class="modal-body">
      <div id="iptbox" style="display:block;">
            <input id="d_ipid_1" type="text" class="form-control" placeholder="请输入导入批号" />
            <input id="d_ipid_2" type="text" class="form-control" placeholder="请重复输入导入批号" />
        </div>
        
        <div id="confirmbox" style="display:none;">
            <h3>以下是该批次导入的部分作品，请确认这是不是您想要删除的批次：</h3>
            <blockquote id="confirmdisp">
                
            </blockquote>
        </div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
        <button id="dip_next" type="button" style="display:inline;" class="btn btn-primary">下一步</button>
        <button id="dip_commit" type="button" style="display:none;" class="btn btn-primary">提交</button>
      </div>
    </div>
  </div>
</div>
<script type="text/javascript">
    window.jurl = "{% url 'pwipidrm' 233333 %}";
    window.eurl = "{% url 'pwipidv' 233333 %}";
    $('#modalDelByIpid').on('hidden.bs.modal', function (e) {
        $("#iptbox").css("display","block");
        $("#confirmbox").css("display","none");
        $("#d_ipid_1").val("");
        $("#d_ipid_2").val("");
        $("#dip_next").css("display","inline");
        $("#dip_commit").css("display","none");
    });
    $("#dip_next").click(function(){
        if($("#d_ipid_1").val()==$("#d_ipid_2").val()){
            window.jpipid = $("#d_ipid_1").val();
            $("#iptbox").css("display","none");
            $("#confirmbox").css("display","block");
            $("#dip_next").css("display","none");
            $("#dip_commit").css("display","inline");
            $("#confirmdisp").html("正在载入...");
            $("#confirmdisp").load(window.eurl.replace(/233333/,window.jpipid));
        }else{
            alert("两次输入的导入批号不一致");
        }
    });
    $("#dip_commit").click(function(){
        window.location.href = window.jurl.replace(/233333/,window.jpipid);
    });
    
</script>
{% endblock %}
