<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2020/9/11
  Time: 12:54
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.util.*" %>
<%@ page import="com.censoft.common.db.ConnectionFactory" %>
<%@ page import="com.censoft.common.base.Pub" %>
<%
    ConnectionFactory cf = new ConnectionFactory();
    Pub pub = new Pub();
    Connection conn = null;
    Vector v_list = null;
    String page_number = pub.trimNull(request.getParameter("page_number"));
    String id = pub.trimNull(request.getParameter("id"));
    String s_dept_id = pub.trimNull(request.getParameter("dept_id"));
    String userid = pub.trimNull(request.getParameter("userid"));
    //System.out.println(s_dept_id+"==="+userid);
    if ("".equals(page_number)) page_number = "1";
    String page_size = pub.trimNull(request.getParameter("page_size"));
    if ("".equals(page_size)) page_size = "10";
    try {
        conn = com.censoft.db.DBUtil.getConnection();
        StringBuffer sb = new StringBuffer();
        List list = new ArrayList();
        sb.append("select t1.*  from t_book_admin t1  where 1=1 ");
        if(!"".equals(s_dept_id)){
            sb.append(" and t1.dept_id = ?");
            list.add(s_dept_id);
        }
        sb.append("  order by t1.add_time desc ");
        v_list = cf.doQuery(conn, sb.toString(), null, list.toArray());
        if (v_list == null) {
            out.println("查询用户出错"+cf.getMsg());
            return;
        }
    } catch (Exception e) {
        out.println("查询用户信息异常" + e);
        return;
    } finally {
        if (conn != null) {
            try {
                conn.close();
            } catch (Exception e) {
            }
        }
    }
    Hashtable ht_row = (Hashtable) v_list.get(0);
    String rowCnt = pub.trimNull((String) ht_row.get("ROWCOUNT"));
%>
<div>
    <a class="btn btn-primary radius" onclick="queren('<%=id%>');">
        确认
    </a>
</div>
<table class="table table-border table-bordered table-hover table-bg table-sort">
    <thead>
    <tr class="text-c">
        <th width="80">选择</th>
        <th width="80">姓名</th>
    </tr>
    </thead>
    <tbody>
    <%
        if (v_list != null && v_list.size() > 0) {
            for (int i = 0; i < v_list.size(); i++) {
                Hashtable ht = (Hashtable) v_list.get(i);
                String login_name = pub.trimNull((String) ht.get("login_name"));
                String login_id = pub.trimNull((String) ht.get("login_id"));
    %>
    <tr class="text-c">
        <td><input type="radio" <%if(userid.equals(login_id)){%>checked="checked"<%}%> name="radio_single" id="radio_single" value="<%=login_id%>_<%=login_name%>"/></td>
        <td><%=login_name%>
        </td>
    </tr>
    <%
            }
        }
    %>
    </tbody>
</table>

<script type="text/javascript">
    /*$('input:radio').click(function(){
        var $radio = $(this);
        if ($radio.data('checked')){
            $radio.prop('checked', false);
            $radio.data('checked', false);
        } else {
            $radio.prop('checked', true);
            $radio.data('checked', true);
        }
    });*/

</script>