<%@ page contentType="text/html; charset=UTF-8"%>
<%@ page import="java.util.*,com.csc.library.bean.*,com.csc.library.controller.*"%>
<%@ page import="com.csc.library.util.*"%>
<jsp:useBean id="search" class="com.csc.library.controller.SearchController" scope="page"/>
<%
	search.setChannel(request, response);
	search.process();	
	CheckUser ch=new CheckUser();	
 	ch.setRequest(request);		
	ch.process();	
%>
<jsp:include page="header.jsp" flush="false" />
<script type="text/javascript">
<!--
function goSearch(){
	with(document.cscform){
		action = "search.jsp";
		act.value = "search";
		submit();
	}
}
function goEnterSearch(){
  		if (window.event && window.event.keyCode == 13){
  			   cal(goSearch());
  		}
}
function MM_jumpMenu(targ,selObj,restore,act){ //v3.0
	if(selObj.options[selObj.selectedIndex].value != ""){		
		var screen_name = window.document.cscform.screen.value;
		eval(targ+".location=\""+screen_name+"?page="+selObj.options[selObj.selectedIndex].value+"&act="+act+"\"");
		if (restore) selObj.selectedIndex=0;		
	}  	
}
//-->
</script>
<form name="cscform" method="post" action="search.jsp">
<input type="hidden" name="act" value=""> 
<input type="hidden" name="screen" value="search.jsp">
<table width="99%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF">
	<tr>
		<td bordercolor="#000000">
		<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#4F5D6F">
			<tr>
				<td class="maintitle">ค้นหาข้อมูล</td>
			</tr>
			<tr>
				<td class="subtitle"></td>
			</tr>
		</table>
		</td>
	</tr>
	<tr>
		<td bordercolor="#CCCCCC" class="td02">
			<div align="center">
				ข้อความค้นหา&nbsp;<input onkeypress="goEnterSearch(event)" name="key_word" type="text" id="key_word" size="50" /> 
				<span class="divbar"> <a href="javascript:goSearch();"><img src="images/b_search.gif" width="62" height="22" align="absmiddle" border="0" /></a></span><br />
				ค้นหาจาก &nbsp;
				<input type="radio" name="searchfrom" value="all" checked="checked" />ทั้งหมด&nbsp;
				<input type="radio" name="searchfrom" value="knowledge" />Knowledge Base&nbsp;
				<input type="radio" name="searchfrom" value="topic" /> เว็บบอร์ด
			</div>
		</td>
	</tr>
</table>
<br />
<%
List lResult = null;
int known_hits = ((Integer)request.getSession().getAttribute("wb_knowledge_hits")).intValue();
if(known_hits !=0 ){
%>
<table width="99%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF">
	<tr>
		<td bordercolor="#000000">
		<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#4F5D6F">
			<tr>
				<td class="maintitle">
					<B>ข้อมูลจาก: Knowledge Base</B> &nbsp;&nbsp;
					ผลการค้นหาข้อมูล: <%=request.getSession().getAttribute("txtToSearch")%>&nbsp; 
					พบข้อมูลทั้งหมด: <%=request.getSession().getAttribute("wb_knowledge_hits")%>&nbsp;เรคคอร์ด.&nbsp;
					ใช้เวลา: <%=request.getSession().getAttribute("wb_knowledge_time")%>&nbsp;วินาที.
					
				</td>
			</tr>
		</table>
		</td>
	</tr>
	<%
		lResult = (List) request.getSession().getAttribute("knownList");
		if (lResult != null) {
			for (int i = 0; i < lResult.size(); i++) {
				Document doc = (Document) lResult.get(i);
	%>
	<tr>
		<td class="subtitle"><%=doc.getTitle()%></td>
	</tr>
	<tr>
		<td bordercolor="#CCCCCC" class="">
		<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#FFFFFF">
			<tr>
				<td>
				<table width="100%" border="0" cellspacing="1" cellpadding="0">
					<tr>
						<td height="60" class="td02top"><%=doc.getIntro()%>
						<BR><B><a href="knowledge.jsp?__fixCon=knowledge_code='<%=doc.getCode()%>'">อ่านต่อ...</a></B>
						</td>
					</tr>
					<tr>
						<td class="td01">
						<div align="right"><strong>สร้างโดย: <%=ch.getUserName(doc.getOwner())%> ,วันที่สร้าง :<%=ch.getDateFormat(doc.getCreateDate())%></strong></div>
						</td>
					</tr>
				</table>
				</td>
			</tr>

		</table>
		</td>
	</tr>
	<%
			}
		}
	%>
</table>
<br />
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="1" class="divbar">
	<tr>
		<td height="25">
		<div align="right">ไปที่หน้า 
		<select name="jumpMenu" id="jumpMenu" onchange="MM_jumpMenu('parent',this,0,'change_known_page')">
			<option value=""></option>
			<%
				if (request.getSession().getAttribute("wb_knowledge_count") != null) {
					int pageCount = ((Integer) request.getSession().getAttribute("wb_knowledge_count")).intValue();
					int curPage = ((Integer) request.getSession().getAttribute("cur_known_page")).intValue();
					for (int i = 0; i < pageCount; i++) {
			%>
			<option value="<%=i%>" <%=(i == curPage ? " selected ":"")%>>หน้า <%=(i + 1)%></option>
			<%
					}
				}
			%>
		</select>
		</div>
		</td>
	</tr>
</table>
<%}%>

<br />
<%
int topic_hits = ((Integer)request.getSession().getAttribute("wb_topic_hits")).intValue();
if(topic_hits !=0 ){
%>
<table width="99%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF">
<tr>
		<td bordercolor="#000000">
		<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#4F5D6F">
			<tr>
				<td class="maintitle">
					<B>ข้อมูลจาก: เว็บบอร์ด</B> &nbsp;&nbsp;
					ผลการค้นหาข้อมูล: <%=request.getSession().getAttribute("txtToSearch")%>&nbsp; 
					พบข้อมูลทั้งหมด: <%=request.getSession().getAttribute("wb_topic_hits")%>&nbsp;เรคคอร์ด.&nbsp;
					ใช้เวลา: <%=request.getSession().getAttribute("wb_topic_time")%>&nbsp;วินาที.
					
				</td>
			</tr>
		</table>
		</td>
	</tr>
	<%
		lResult = (List) request.getSession().getAttribute("topicList");
		if (lResult != null) {
			for (int i = 0; i < lResult.size(); i++) {
				Document doc = (Document) lResult.get(i);
	%>
	<tr>
		<td class="subtitle"><%=doc.getTitle()%>
		
		</td>
	</tr>
	<tr>
		<td bordercolor="#CCCCCC" class="">
		<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#FFFFFF">
			<tr>
				<td>
				<table width="100%" border="0" cellspacing="1" cellpadding="0">
					<tr>
						<td height="60" class="td02top"><%=doc.getIntro()%>
						<BR><B><a href="topicdetail.jsp?__fixCon=topic_id=<%=doc.getCode()%>">อ่านต่อ...</a></B>
						</td>
					</tr>
					<tr>
						<td class="td01">
						<div align="right"><strong>สร้างโดย: <%=ch.getUserName(doc.getOwner())%> ,วันที่สร้าง :<%=ch.getDateFormat(doc.getCreateDate())%></strong></div>
						</td>
					</tr>
				</table>
				</td>
			</tr>

		</table>
		</td>
	</tr>
	<%
			}
		}
	%>
</table>
<br />
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="1" class="divbar">
	<tr>
		<td height="25">
		<div align="right">ไปที่หน้า 
		<select name="jumpMenu" id="jumpMenu" onchange="MM_jumpMenu('parent',this,0,'change_topic_page')">
			<option value=""></option>
			<%
				if (request.getSession().getAttribute("wb_topic_count") != null) {
					int pageCount = ((Integer) request.getSession().getAttribute("wb_topic_count")).intValue();
					int curPage = ((Integer) request.getSession().getAttribute("cur_topic_page")).intValue();
					for (int i = 0; i < pageCount; i++) {
			%>
			<option value="<%=i%>" <%=(i == curPage ? " selected ":"")%>>หน้า <%=(i + 1)%></option>
			<%
					}
				}
			%>
		</select>
		</div>
		</td>
	</tr>
</table>
</td>
</tr>
</table>
<%}%>
</form>

<jsp:include page="footer.jsp" flush="false" />