<%--
  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 s_id = pub.trimNull((String) session.getAttribute("session_login_id"));
    String s_login_name = pub.trimNull((String) session.getAttribute("session_login_name"));
    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 zc_name_s = pub.trimNull(request.getParameter("zc_name"));
    String zc_id = pub.trimNull(request.getParameter("zc_id"));
    String pinpai = pub.trimNull(request.getParameter("pinpai"));
    String zc_status_s = pub.trimNull(request.getParameter("zc_status"));
    String b_time = pub.trimNull(request.getParameter("b_time"));
    String e_time = pub.trimNull(request.getParameter("e_time"));
    if ("".equals(page_size)) page_size = "10";
    List list_s = new ArrayList();
    try {
        StringBuffer sb = new StringBuffer();
        sb.append("select t1.zc_id,t1.zc_name,t1.pinpai,t1.jiazhi,t1.add_time,t1.zc_status,t2.ly_id,ly_time,bg_time from zc_register t1 join " +
                "zc_ly t2 on t1.zc_id=t2.zc_id where t2.ly_status='3' ");
        if(!"".equals(zc_name_s)){
            sb.append(" and t1.zc_name like ?");
            list_s.add("%"+zc_name_s+"%");
        }if(!"".equals(zc_id)){
            sb.append(" and t1.zc_id like ?");
            list_s.add("%"+zc_id+"%");
        }if(!"".equals(pinpai)){
            sb.append(" and t1.pinpai like ?");
            list_s.add("%"+pinpai+"%");
        }if(!"".equals(zc_status_s)){
            sb.append(" and zc_status = ?");
            list_s.add(zc_status_s);
        }if(!"".equals(b_time)){
            sb.append(" and t2.ly_time >= ?");
            list_s.add(b_time);
        }if(!"".equals(e_time)){
            sb.append(" and t2.ly_time <= ?");
            list_s.add(e_time);
        }
        if(!"admin".equals(s_id)){
            sb.append(" and t2.ly_user = ?");
            list_s.add(s_login_name);
        }
        sb.append(" order by t2.ly_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 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 zc_id_view = pub.trimNull((String) ht.get("zc_id"));
                        String ly_id_view = pub.trimNull((String) ht.get("ly_id"));
                        String zc_name = pub.trimNull((String) ht.get("zc_name"));
                        String pinpai_view = pub.trimNull((String) ht.get("pinpai"));
                        String jiage = pub.trimNull((String) ht.get("jiazhi"));
                        String bg_time = pub.trimNull((String) ht.get("bg_time"));
                        String zc_status_view = pub.trimNull((String) ht.get("zc_status"));
                        String wx_button="维修";
                        String wx_type="doing";
                        if("3".equals(zc_status_view)){
                            zc_status_view="已领用";
                        }else if("5".equals(zc_status_view)){
                            zc_status_view="维修中";
                            wx_button="完成";
                            wx_type="done";
                        }else if("6".equals(zc_status_view)){
                            zc_status_view="报废";
                        }
                        if(!"".equals(bg_time)){
                            zc_status_view="变更";
                        }
                        String cw_date = pub.trimNull((String) ht.get("ly_time"));

                        %>
                        <tr <%if(i%2==0){%>id="tr_doub"<%}else{%>id="tr_single"<%}%> class="text-c">
                            <td><%=zc_id_view%>
                            </td>
                            <td><%=zc_name%>
                            </td>
                            <td><%=pinpai_view%>
                            </td>
                            <td><%=jiage%>
                            </td>
                            <td><%=cw_date%>
                            </td>
                            <td><%=zc_status_view%>
                            </td>
                            <td>
                                <a title="详情" href="javascript:void(0);" onclick="updateById('详情','./list_add-t.jsp?update_id=<%=ly_id_view%>&zc_id=<%=zc_id_view%>');" class="ml-5" >
                                    <i class="Hui-iconfont">详情</i>
                                </a>
                                <%if(!"报废".equals(zc_status_view)){%>
                                <a title="<%=wx_button%>" href="javascript:void(0);" <%if("doing".equals(wx_type)){%>onclick="updateById('维修','./list_wx-t.jsp?wx_type=<%=wx_type%>&update_id=<%=zc_id_view%>');"<%}else{%>
                                   onclick="wxOkById('<%=wx_type%>','<%=zc_id_view%>');"
                                        <%}%> class="ml-5" >
                                    <i class="Hui-iconfont"><%=wx_button%></i>
                                </a>
									<%if(!"维修中".equals(zc_status_view)){%>
										<a title="报废" href="javascript:void(0);" onclick="updateById('报废','./list_bf-t.jsp?update_id=<%=zc_id_view%>');" class="ml-5" >
											<i class="Hui-iconfont">报废</i>
										</a>
										<a title="变更" href="javascript:void(0);" onclick="updateById('变更','./list_bg-t.jsp?update_id=<%=zc_id_view%>&ly_id=<%=ly_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) {
            }
        }
    }
%>