{% 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 "listuserurl" as thelistuserurl %}
            <a class="btn btn-default {%if request.path = thelistuserurl%} active {%endif%}" href={{ thelistuserurl }}><span class="glyphicon glyphicon-list"></span>用户列表</a>
            {% url "removesusersurl" as theremovesusersurl %}
            <a class="btn btn-default {%if request.path = theremovesusersurl%} active {%endif%}" href={{ theremovesusersurl }}><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>账号</th>
            <th>姓名</th>
            <th>性别</th>
            <th>学号</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.username }}</td>
                    <td>{{ i.nickname|default:"----" }}</td>
                    <td>{{ i.sex|default:"----" }}</td>
                    <td>{{ i.sid }}</td>
                    <td>{{ i.classid }}</td>
                    <td>
                        {% if i.is_active %}
                            <span class="label label-success">启用</span>
                        {% else %}
                            <span class="label label-default">禁用</span>
                        {% endif %}
                    </td>
                    <td>{{ i.role|default:"----" }}</td>
                    <td>{{ i.importid }}</td>
                    <td>{{ i.last_login|date:"Y-m-d H:i:s" }}</td>
                    <td class="host_buttom">
                        <a class="btn btn-warning btn-xs"  href={% url "edituserurl" i.id %} onclick="return confirm('是否确认编辑？')">编辑</a>
                        <a class="btn btn-danger btn-xs" href={% url "deleteuserurl" 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 'removesusersbyipid' 233333 %}";
    window.eurl = "{% url 'expusersbyipid' 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 %}
