
<%
/************************************************************@@
  * Program Name	: board_list.jsp
  * Description		: /
  * Author				: 조용준
  * Create Date		: 2004.11.08
  * History				:
@@************************************************************/
%>
<%@ page contentType="text/html; charset=UTF-8"
	import="java.text.SimpleDateFormat" import="java.util.Date"
	import="java.util.List" import="javax.jdo.Extent"
	import="javax.jdo.PersistenceManager" import="javax.jdo.Transaction"
	import="javax.jdo.Query" import="kr.co.kihyun.beans.entity.*"
	import="kr.co.kihyun.beans.entity.util.*"
	import="kr.co.kihyun.beans.user.HttpSSOLogin"
	import="kr.co.kihyun.lang.MString"
	import="kr.co.kihyun.lang.StringConverter"
	import="kr.co.kihyun.moumi.MoumiConfig"
	import="kr.co.kihyun.text.html.ServletUtil"
	import="kr.co.kihyun.util.MDate"%>

<%@ include file="/totsys/common/inc/sec/secure.inc.jsp"%>

<%
	PersistenceManager pm = new MPersistenceManager(PMF.get().getPersistenceManager());
	Transaction tx = pm.currentTransaction();
	try{
		/********** session내의 userId **********/
		String usID = HttpSSOLogin.getLoginID(request);
		int sysAuth = HttpSSOLogin.getSysAuth(request);

		int titleLengthLimit = 15;
		Long boardCountLimit = 3L;

		Category category = pm.getObjectById(Category.class, request.getParameter("boardGroupID"));

		List<Board> boardList;
		Query q = pm.newQuery(Board.class);
		q.setFilter("category == board_category");
		q.declareParameters("kr.co.kihyun.beans.entity.Category board_category");
		q.setRange(0L, boardCountLimit);
                //v2. 13.SQL 삽입 : JDO형식이므로 해결책에 따른 prepare SQL 문으로 변경할 수 없음
  		boardList = (List<Board>) q.execute(category);
                //================
%>
<html>
<head>
<SCRIPT>
		function viewBoard(boardID,boardUserID){
			location.href="/totsys/sysadm/board/board_view.jsp?boardID="+boardID+"&boardUserID="+boardUserID;
		}
	</SCRIPT>
</head>
<body>
<table width="380" height="25" border="0" cellpadding="0"
	cellspacing="0">
	<tr>
		<td align="left" style="font-size: 13pt; color: black">
                    <img align="bottom" src="/totsys/common/images/title.jpg" border="0">&nbsp;&nbsp;<b><%= category.getName() %></b>
		</td>
		<td width="25">
                    <a href="/totsys/sysadm/board/board_list.jsp?boardGroupID=<%= category.getId() %>">
		<img src="/totsys/common/images/more.jpg" alt="go" border="0" /></a></td>
	</tr>
</table>
<table width="380" border="0" cellspacing="0" cellpadding="0">
	<tr>
		<td width="10" height="10"><img src="/totsys/common/images/p_box01_001.gif" width="10" height="10"></td>
		<td height="10" background="/totsys/common/images/p_box01_002.gif"></td>
		<td width="10" height="10"><img src="/totsys/common/images/p_box01_003.gif" width="10" height="10"></td>
	</tr>
	<tr>
		<td background="/totsys/common/images/p_box01_008.gif">&nbsp;</td>
		<td>
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
			<tr style="padding-top: 15px;">
				<td>
				<table width="100%" border="0" cellspacing="0" cellpadding="0">
					<%
		int blank=0;
		tx.begin();
		for(int i=0; i < boardCountLimit; i++, blank++){
			%>
					<tr bgcolor="<%= (blank%2) ==0 ? "FFFFFF" : "F4F4F4"%>">
						<td height="23">
						<% if(i < boardList.size()) { %> <img src="images/bu_002.gif"
							width="8" height="7" hspace="5" /> <a href="#"
							onclick="<%if(MoumiConfig.isOnTopMenu()&& HttpSSOLogin.getSysAuth(request)==MoumiConfig.TOTPER){%>openTop(3);<%}else{%>openTop(1);<%}%>viewBoard('<%=boardList.get(i).getId()%>','<%=boardList.get(i).getUser(pm).getId()%>');"
							class="f_12_p_L"><%= MString.getEllipsis(boardList.get(i).getTitle(), titleLengthLimit) %></a>
						<% } else { %> &nbsp; <% } %>
						</td>
						<td width="80" align="center" class="f_11_site">
						<% if(i < boardList.size()) { %> <%= new SimpleDateFormat("yyyy-MM-dd").format(boardList.get(i).getWriteDate()) %>
						<% } else { %> &nbsp; <% } %>
						</td>
					</tr>
					<%
		}
		tx.rollback();
	%>
				</table>
				</td>
			</tr>
		</table>
		</td>
		<td background="/totsys/common/images/p_box01_004.gif">&nbsp;</td>
	</tr>
	<tr>
		<td width="10" height="10"><img src="/totsys/common/images/p_box01_007.gif" width="10" height="10"></td>
		<td height="10" background="/totsys/common/images/p_box01_006.gif"></td>
		<td height="10"><img src="/totsys/common/images/p_box01_005.gif" width="10" height="10"></td>
	</tr>
</table>
</body>
</html>
<%
}catch(Exception e){
	System.err.println("param: "+request.getParameter("boardGroupID"));
	e.printStackTrace();
}finally{
	if(tx.isActive())
		tx.rollback();
	pm.close();
}
%>
