<%--
  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" %>
<%@ page import="org.omg.CosCollection.IteratorInBetween" %>
<%!
    Pub pub = new Pub();
    public int getCounts(ConnectionFactory cf,Connection conn,String id){
        Vector list = cf.doQuery(conn,"select * from zc_register where zc_status='0' and reg_id=?",null,new Object[]{id});
        if(list==null){
            System.out.println("查询出错"+cf.getMsg());
        }
        return list.size();
    }
%>
<%
    ConnectionFactory cf = new ConnectionFactory();
    Pub pub = new Pub();
    Connection conn = null;
    Vector v_list = null;
    String page_number = pub.trimNull(request.getParameter("page_number"));
    if ("".equals(page_number)) page_number = "1";
    String page_size = pub.trimNull(request.getParameter("page_size"));
    String pd_number = pub.trimNull(request.getParameter("pd_number"));
    String pd_user = pub.trimNull(request.getParameter("pd_user"));
    String zc_fl_s = pub.trimNull(request.getParameter("zc_fl"));
    String jz_type_s = pub.trimNull(request.getParameter("jz_type"));
    String pd_status = pub.trimNull(request.getParameter("pd_status"));
    String b_time = pub.trimNull(request.getParameter("pd_b_time"));
    String e_time = pub.trimNull(request.getParameter("pd_e_time"));
    if ("".equals(page_size)) page_size = "10";
    List list_s = new ArrayList();
    try {
        StringBuffer sb = new StringBuffer();
        sb.append("select distinct pd_id,pd_number,pd_user,beizhu,pd_status,pd_b_time,pd_e_time,add_time from zc_pd where 1=1 ");
        if(!"".equals(pd_number)){
            sb.append(" and pd_number like ?");
            list_s.add("%"+pd_number+"%");
        }if(!"".equals(pd_user)){
            sb.append(" and pd_user like ?");
            list_s.add("%"+pd_user+"%");
        }if(!"".equals(pd_status)){
            sb.append(" and pd_status = ?");
            list_s.add(pd_status);
        }if(!"".equals(b_time)){
            sb.append(" and pd_b_time >= ?");
            list_s.add(b_time);
        }if(!"".equals(e_time)){
            sb.append(" and pd_e_time <= ?");
            list_s.add(e_time);
        }
        sb.append(" order by add_time desc");
        conn = com.censoft.db.DBUtil.getConnection();
        v_list = cf.doPageQueryWithCount(conn, sb.toString(), page_number, page_size, null, list_s.toArray());
        if (v_list == null) {
            out.println("查询出错" + cf.getMsg());
            return;
        }

    Hashtable ht_row = (Hashtable) v_list.get(0);
    String rowCnt = pub.trimNull((String) ht_row.get("ROWCOUNT"));
    String pageCnt = pub.trimNull((String) ht_row.get("PAGECOUNT"));
    String telSegmentUrl="./list_add-t.jsp";
%>
<div>
    <a class="btn btn-primary radius" onclick="addRules('盘点','<%=telSegmentUrl%>');" >
        新增盘点
    </a>
</div>
<div class="table-list">
    <table class="table  table-hover table-bg">
        <thead>
        <tr class="text-c">
            <th width="50px">盘点单号</th>
            <th width="50px">盘点人</th>
            <th width="50px">盘点说明</th>
            <th width="50px">盘点状态</th>
            <th width="50px">盘点开始时间</th>
            <th width="50px">盘点结束时间</th>
            <th width="50px">盘点清单</th>
        </tr>
        </thead>
        <tbody>
        <%
            if (v_list != null && v_list.size() > 0) {
                    for (int i = 1; i < v_list.size(); i++) {
                        Hashtable ht = (Hashtable) v_list.get(i);
                        String pd_number_view = pub.trimNull((String) ht.get("pd_number"));
                        String pd_id_view = pub.trimNull((String) ht.get("pd_id"));
                        String pd_user_view = pub.trimNull((String) ht.get("pd_user"));
                        String beizhu_view = pub.trimNull((String) ht.get("beizhu"));
                        String pd_status_view = pub.trimNull((String) ht.get("pd_status"));
                        if("0".equals(pd_status_view)){
                            pd_status_view="盘点中";
                        }else if("1".equals(pd_status_view)){
                            pd_status_view="盘点结束";
                        }
                        String pd_b_time = pub.trimNull((String) ht.get("pd_b_time"));
                        String pd_e_time = pub.trimNull((String) ht.get("pd_e_time"));

                        %>
                        <tr <%if(i%2==0){%>id="tr_doub"<%}else{%>id="tr_single"<%}%> class="text-c">
                            <td><%=pd_number_view%>
                            </td>
                            <td><%=pd_user_view%>
                            </td>
                            <td><%=beizhu_view%>
                            </td>
                            <td><%=pd_status_view%>
                            </td>
                            <td><%=pd_b_time%>
                            </td>
                            <td><%=pd_e_time%>
                            </td>

                            <td>
                                <a title="详情" href="javascript:void(0);" onclick="infoView('<%=pd_number_view%>','<%=pd_user_view%>');" class="ml-5" >
                                    <i class="Hui-iconfont">详情</i>
                                </a>
                                <%if(!"盘点结束".equals(pd_status_view)){
                                %>
                                <a title="盘点完成" href="javascript:void(0);" onclick="pdEnd('<%=pd_id_view%>');" class="ml-5" >
                                    <i class="Hui-iconfont">盘点完成</i>
                                </a>
                                <%}%>
                            </td>
                        </tr>
                        <%
                    }
            }
        %>
        </tbody>
    </table>
</div>
<jsp:include page="/common/page_ajax.jsp" >
    <jsp:param name="page_number" value="<%=page_number%>" />
    <jsp:param name="rowCnt" value="<%=rowCnt%>" />
    <jsp:param name="page_size" value="<%=page_size%>" />
</jsp:include>
<%
    } catch (Exception e) {
        out.println("查询异常" + e);
        return;
    } finally {
        if (conn != null) {
            try {
                conn.close();
            } catch (Exception e) {
            }
        }
    }
%>