<%@page contentType="text/html; charset=UTF-8"%>
<%@include file="/inc/init.jsp" %>
<%@include file="/inc/checklogin.jsp" %>
<%@include file="inc/header.jsp" %>
<%
	//分页参数
	int pagex = pu.getInt("pagex", 1);
	if (pagex < 1) {
		pagex = 1;
	}
	int length = 15;
	int start = (pagex - 1) * length;
	int count = 0;
	String querystr = pu.getQueryString();
	querystr=request.getRequestURI()+"?"+querystr;
	//分页参数
Product_db pdb=new  Product_db();
String keyword=pu.getStringByPage("keyword");
DOC[] docs=null;
int classid=pu.getInt("classid");
if(StringUtil.isFine(keyword)&&classid>0){  //如果是双过滤条件
	docs=pdb.searchAndClass(classid,keyword,start,length);
	count=pdb.getRealCount();
}else if(StringUtil.isFine(keyword)){  //如果是关键词搜索
	docs=pdb.search(keyword,start,length);
	count=pdb.getRealCount();
}else if(classid>0){//如果是类别过滤
	docs=pdb.getListByClassid(classid,start,length); //分页参数应用
	count=pdb.getRealCount();
}else{
	docs=pdb.getList(start,length); //分页参数应用
	count=pdb.getRealCount();
}

DOC[] classdocs=null;
Product_class_db pcdb=new Product_class_db();
classdocs=pcdb.getListAll();
%>
<div id="c">
<%@include file="inc/left.jsp" %>
<div id="right">
<%@include file="inc/position.jsp" %>
<div class="right">
<div id="right_box">
	<div class="blank20"></div>
 <div style="float:left;width:600px;margin-left:10px;overflow:hidden;">
     <form name="searchform" id="searchform"  action="productList.jsp" method="get">
       <br />
            <table width="100%" border="0" cellspacing="1">
              <tr>
                <td width="75%">产品名称：
                    <input type="text" name="keyword" id="keyword" value="<%=keyword%>" class="input" />
                  <input type="submit" value="搜索" name="seach"  class="btn_e" /></td>
                <td width="25%" align="center" valign="middle"><div style="float:right;width:150px;overflow:hidden;">
                  <input type="button" value="添加产品" onclick="javascript:window.location.href='productAdd.jsp'"  class="btn_c" />
                </div></td>
              </tr>
              <tr>
                <td valign="middle"><br />
                  产品分类：
                  <select name="classid" id="classid" class="select" onchange="this.form.submit();">
                  <option value="">不限</option>
                    <%
	for(int i=0;i<classdocs.length;i++){
	%>
                    <option value="<%=classdocs[i].get("classid")%>" <%=classdocs[i].geti("classid")==classid?"selected":""%>><%=classdocs[i].get("name")+classdocs[i].get("retain3")%></option>
                    <%}%>
                  </select></td>
                <td width="25%">&nbsp;</td>
                </tr>
            </table>
            <br />
            <div class="blank5"></div>
            </form>
</div>

  <div class="blank5"></div>
<div id="tagscontent" class="right_box">
    <table border="0" cellspacing="0" cellpadding="0" class="list" name="table1" id="table1" width="100%">
        <thead>
            <tr class="th">
                <th width="8%"><!--aid-->
                  产品编号</th>
                <th width="38%"><!--catid-->产品名字</th>
                <th width="16%"><!--title-->
                  所属分类</th>
                <th width="13%"><!--title-->是否选中</th>
                <th width="7%"><!--title-->
                  排序</th>
                <th width="7%"><!--title-->
                  价格</th>
                <!-- <th>作者</th> -->
                <th width="11%" align="center">操作</th>
            </tr>

        </thead>
        <tbody>
        <%
        	DOC doc=null;
                for(int i=0;i<docs.length;i++){
        	doc=pcdb.getOne(docs[i].geti("classid"));
        %>
           <tr class="s_out">
                <td align="center" style="padding:6px 0px"><%=docs[i].get("productid") %></td>
                <td align="center" style="padding:6px 0px" onmouseover="tooltip.show('<%=docs[i].get("name")%>');" onmouseout="tooltip.hide();"><a href="productView.jsp?productid=<%=docs[i].get("productid")%>"><%=Util.sub_String(docs[i].get("name"),36,"..") %></a></td>
                <td align="center" style="padding:6px 0px"><%=doc.get("name")+ doc.get("retain3")%></td>
                <td align="center" style="padding:6px 0px"><%=docs[i].geti("isshow")==1?"是":docs[i].geti("isshow")==0?"否":"停用" %></td>
                <td align="center" style="padding:6px 0px"><%=docs[i].get("sequence") %></td>
                <td align="center" style="padding:6px 0px"><%=docs[i].get("price2") %></td>
                <td align="center" style="padding:6px 0px">
                  <span class="hotspot" onmouseover="tooltip.show('点击编辑内容');" onmouseout="tooltip.hide();"><a href="productEdit.jsp?productid=<%=docs[i].get("productid") %>" class="a_edit"></a></span>
                  <%if(ConfigUtil.usedel){%><span class="hotspot" onmouseover="tooltip.show('确定要删除吗？');" onmouseout="tooltip.hide();"><a onclick="javascript: return confirm('确实要删除吗?删除后不可恢复！');" href="fun/F_product.jsp?action=del&productid=<%=docs[i].get("productid") %>" class="a_del"></a></span><%}%>
                </td>
            </tr>
           <%
           }
		   classdocs=null;
           docs=null;  //释放对象 
		   doc=null;
        %>

        </tbody>
    </table>

<div class="page" align="center">
<%=PagingUtil.splitPages(pagex,querystr,count, length)%> 
</div>
<div class="blank10"></div>
</div>


<div class="blank10"></div>
<div class="blank10"></div>

<div class="clear"></div>
</div>
</div>

<div class="right_bottom">
</div>
</div>

<div id="footer">
</div>
</div>
<%@include file="inc/msg.jsp" %>
<%@include file="inc/footer.jsp" %>
