%
/***********************************************************
* @@ Program Name : doc_list.jsp
* @@ Description : /Áý°èÀÚ/³»¹®¼ÇÔ/ÁøÇàÇÔ/¹®¼ ¸ñ·Ï
* @@ Author : ±âÇöÅ×Å©
* @@ Create Date : 2010.11.18
* @@ History : 2014.09.30 Update by KWON,HAN : ÆäÀÌ¡ ó¸®ÇÏ¿© ÆäÀÌÁöº°·Î ºÒ·¯¿Àµµ·Ï Äõ¸® ¼öÁ¤
* @@*******************************************************
*/
%>
<%@ page contentType="text/html; charset=euc-kr"
import="java.net.URLEncoder"
import="java.net.URLDecoder"
import="java.util.List"
import="java.util.Map"
import="java.util.HashMap"
import="java.util.Date"
import="java.util.Calendar"
import="java.text.SimpleDateFormat"
import="javax.jdo.PersistenceManager"
import="javax.jdo.Transaction"
import="kr.co.kihyun.beans.user.HttpSSOLogin"
import="kr.co.kihyun.lang.Encoder"
import="kr.co.kihyun.lang.MInteger"
import="kr.co.kihyun.lang.MString"
import="kr.co.kihyun.moumi.MoumiConfig"
import="kr.co.kihyun.moumi.Moumi"
import="kr.co.kihyun.beans.entity.util.*"
import="org.slf4j.Logger"
import="org.slf4j.LoggerFactory"
import="kr.co.kihyun.service.TotDocService"
import="kr.co.kihyun.service.vo.TotDocVO"%>
<%@ include file="/totsys/common/inc/sec/secure.inc.jsp"%>
<% PersistenceManager pm = new MPersistenceManager(PMF.get().getPersistenceManager());
Transaction tx = pm.currentTransaction();
try {
Logger LOG = LoggerFactory.getLogger(this.getClass());
/**
* ******** session³»ÀÇ userId *********
*/
String usID = HttpSSOLogin.getLoginID(request);
String dpID = HttpSSOLogin.getDeptID(request);
int sysAuth = HttpSSOLogin.getSysAuth(request);
/**
* **** Parameter *****
*/
String docType = clearXSS(request.getParameter("docType"), null);
int strPage = MInteger.parseInt(request.getParameter("strPage"), 1);
if(strPage <= 0) { strPage = 1; }
String findOption = clearXSS(request.getParameter("findOption"), "");
String findWord = clearXSS(Encoder.toJava(request.getParameter("findWord")), "");
// String method = clearXSS(request.getParameter("method"), "");
//
// if (method.equals("GET")) {
// findWord = URLDecoder.decode(MString.checkNull(request.getParameter("findWord")), "UTF-8");
// }
// String uri = URLEncoder.encode("doc_list.jsp?docType=" + MString.checkNull(docType) + "&findOption=" + MString.checkNull(findOption), "UTF-8") + "&method=GET";
String stDate = clearXSS(request.getParameter("stDate"),"");
String edDate = clearXSS(request.getParameter("edDate"),"");
SimpleDateFormat dForomat = new SimpleDateFormat("yyyy-MM-dd");
Calendar date = Calendar.getInstance();
date.add(Calendar.MONTH, -12);
Long prev_date = date.getTimeInMillis();
Long now_today = new Date().getTime();
if("".equals(stDate)) {
stDate = dForomat.format(prev_date);
}
if("".equals(edDate)) {
edDate = dForomat.format(now_today);
}
int wordLengthLimit = 30;
/************ ¸®½ºÆ® ÆäÀÌÁö ±¸¼º ************/
int pageSize = 0;
int currentPage = 0;
int currentPageSetUp = 0;
int recordSize = 3;
currentPage = strPage;
currentPageSetUp = (int) (currentPage / 10) * 10;
if (currentPage % 10 == 0) {
currentPageSetUp -= 10;
}
tx.begin();
if (!"PRSS".equals(docType) && !"REG".equals(docType) && !"END".equals(docType)) {
LOG.error("docType is not specified.");
}
//======================================================================
TotDocService docService = new TotDocService(pm);
//°Ë»öÁ¶°ÇÆÄ¶ó¹ÌÅÍ
Map params = new HashMap();
params.put("userId", usID);
params.put("deptId", dpID);
params.put("findOption", findOption);
params.put("filterValue", findWord);
//°Ë»ö¸ÞÀÎÄõ¸®¿Í ·¹Äڵ尹¼öÁ¶È¸Äõ¸®¸¦ »ý¼º ÈÄ ¸â¹öº¯¼ö·Î ÀúÀå
docService.createDocListSearchQuery(params, docType);
//·¹Äڵ尹¼öÁ¶È¸Äõ¸®¸¦ ½ÇÇàÇÏ¿© ·¹Äڵ尹¼ö¸¦ ±¸ÇÔ
int count = docService.getCountFromMainQuery();
if((count%recordSize) == 0){
pageSize = (int)(count/recordSize);
}else{
pageSize = (int)(count/recordSize)+1;
}
if( currentPage > pageSize ) currentPage = pageSize;
int startNo = (currentPage - 1) * recordSize + 1;
int endNo = currentPage * recordSize;
List list = null;
//°Ë»ö¸ñ·ÏÁ¶È¸Äõ¸® ½ÇÇà
if( count > 0 ) {
//ÆäÀ̡󸮸¦ À§ÇÑ Ãß°¡ÆÄ¶ó¹ÌÅÍ ¼³Á¤
docService.getParams().put("startNo", startNo);
docService.getParams().put("endNo", endNo);
//°Ë»ö¸ÞÀÎÄõ¸®¸¦ ÆäÀ̡󸮸¦ À§ÇÑ Äõ¸®·Î º¯È¯
docService.convertToPagenatingQuery();
//¸¸Á·ÇÏ´Â ·¹Äڵ尡 Á¸ÀçÇϸé Á¶È¸
list = docService.executeQuery(TotDocVO.class);
}
//======================================================================
tx.rollback();
%>
<%=Moumi.getTitle()%>
<%
tx.begin();
int index = 0; //¹è¿¿¡¼ °ªÀ» ²¨³»¿À´Â ۰ª
// int nextCount = 0; //
//
// if (currentPage > 1) {
// nextCount = ((currentPage - 1) * recordSize);
// }
if( count > 0 ) {
int listCount = list.size();
for(int i = 0; i < listCount ; i++){
// index = nextCount + i;
TotDocVO docVO = (TotDocVO)list.get(i);
%>
<%
if ("PRSS".equals(docType)) {
%>
<%= MString.getEllipsis(docVO.getName(), wordLengthLimit)%>
<%
}
%>
<%= MString.checkNull(docVO.getDeptName())%>
<%= docVO.getOwnerName()%>
<%= docType.equals("REG") ? new SimpleDateFormat("yyyy-MM-dd HH:mm").format(docVO.getStartDate()) : new SimpleDateFormat("yyyy-MM-dd").format(docVO.getStartDate())%>
>
<%
out.write(tmp2 + tstr + tcnt);
%>
<%
out.write(docVO.getSndCnt() + "/" + docVO.getAllCnt());
%>
<%
} //end of for list
} //end of if( count > 0)
else
{
%>
ÃëÇÕÁßÀÎ ÀÚ·á°¡ ¾ø½À´Ï´Ù.
<%
}
tx.rollback();
%>
<%
} catch (Exception ex) {
ex.printStackTrace();
out.println(kr.co.kihyun.text.html.ServletUtil.getJavaScript("location='/servlet/kr.co.kihyun.beans.user.HttpSSOLogin?mode=logout';"));
} finally {
if (tx.isActive()) {
tx.rollback();
}
pm.close();
}
%>