<%@ page contentType="text/html; charset=UTF-8"
	import="kr.co.kihyun.beans.user.HttpSSOLogin"
	import="kr.co.kihyun.text.html.ServletUtil"
	import="kr.co.kihyun.beans.user.User"
	import="kr.co.kihyun.beans.totsys.repoper.RepTransfer"
	import="kr.co.kihyun.lang.MInteger" import="kr.co.kihyun.lang.MLong"
	import="kr.co.kihyun.lang.Encoder" import="kr.co.kihyun.moumi.Moumi"%>

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

<%
try{
	/*********** User HttpSSOLogin check ***********/
	if(!HttpSSOLogin.isLogin(request)){
		//login 성공후 되돌아올 주소
		String connURL="opener.location='/totsys/login/login.jsp';";		
		out.println(ServletUtil.getJavaScript(connURL));
		out.println(ServletUtil.getJavaScript("window.close();"));
		return;
	}

	/********** session내의 userId **********/		
	String userID = HttpSSOLogin.getLoginID(request);

	/****** Parameter ******/
	Long docID = MLong.parseLong(request.getParameter("docID"),null);
	String deptID = request.getParameter("deptID");
	int strPage = MInteger.parseInt(request.getParameter("strPage"), 1);
	String dataType = clearXSS(Encoder.toJava(request.getParameter("dataType")),"");
	int sys_auth = 2;
	String boxName = clearXSS(Encoder.toJava(request.getParameter("boxName")),"");
	String option = clearXSS(Encoder.toJava(request.getParameter("option")),"");
	String findword = clearXSS(Encoder.toJava(request.getParameter("findword")),"");
	String addString = "";
	String select = clearXSS(request.getParameter("select"),"");

	/****** list data get ******/
	int count = 0;	
	String[] userIDList = null;
	String[] changeUserIDList = null;
	String[] changeUserDateList = null;	

	RepTransfer rt = new RepTransfer();
	User us = new User();
	rt.userTransListQuery(docID, deptID);

	count = rt.getCount();
	userIDList = rt.getUserIDList();
	changeUserIDList = rt.getChangeUserIDList();
	changeUserDateList = rt.getChangeUserDateList();	

	/************ 리스트 페이지 구성 ************/
	int endPage = 0;
	int pageSize =0 ;
	int currentPage = 0;
	int absolutePage = 0;		
	int currentPageSetUp = 0;
	int recordSize = 15;	
	
	currentPage=strPage;

	if((count%recordSize) == 0){
		pageSize = (int)(count/recordSize);	
	}else{
		pageSize = (int)(count/recordSize)+1;	
	}

	currentPageSetUp = (int)(currentPage/10)*10; 
	if (currentPage%10 == 0){
		currentPageSetUp-=10;
	}
	//page link 
	//String uri = "./report_list.jsp?docID="+ docID +"&dataType="+ dataType;
	String uri = "./popup_list.jsp?docID="+ docID +"&deptID="+deptID;
%>

<html>
<head>
<title><%=Moumi.getTitle()%></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="/totsys/common/css/text.css"
	type="text/css">
<link rel="stylesheet" href="/totsys/common/css/kecttep.css"
	type="text/css">
<script src="/totsys/common/js/rollover.js"></script>
<script language="javascript">
			function transForm(usID){
				var frm = document.transfer;		 
				frm.userID.value=usID;

				if(confirm('담당자를 변경 하시겠습니까?')){
						frm.submit();
				}else{
						window.close();
				}
			}

			function find(){
				var word = document.search.findword.value.length;
				var option = document.search.select.options[document.search.select.selectedIndex].value;
				document.search.option.value = option;

				if( option != "all" && word < 2){
					alert("검색어는 2글자 이상이어야 합니다.!");
				}
				
				document.search.submit();
			}
		</script>
</head>

<body style='' leftmargin="0" topmargin="0" marginwidth="0"
	marginheight="0">
<FORM name="transfer"
	action="/servlet/kr.co.kihyun.beans.totsys.repoper.HttpTransfer"
	method="post"><INPUT type="hidden" name="docID"
	value="<%= docID %>"> <INPUT type="hidden" name="boxName"
	value="<%= boxName %>"> <INPUT type="hidden" name="userID"
	value=""></FORM>
<table width="530" border="0" cellpadding="0" cellspacing="0">
	<!--- 리스트 시작 ---->
	<tr>
		<td>
		<table border="1px" class="kecttep_list_table" width="100%"
			cellpadding="0" cellspacing="0">
			<tr valign="middle" style="padding-top: 3">
				<td align="center" nowrap class="kecttep_tdmenu">변경전 담당자</td>
				<td align="center" class="kecttep_tdmenu">변경후 담당자</td>
				<td align="center" nowrap class="kecttep_tdmenu">변경 일자</td>
			</tr>
			<%
			int index = 0;     
			int nextCount = 0; 

			if(currentPage > 1){
					nextCount = ((currentPage-1)*recordSize);
			}
								
			for(int i = 0; (i < recordSize) && ((nextCount+i) < count); i++){
					index = nextCount+i;
%>
			<tr style="padding-top: 3" valign="middle"
				onmouseover="this.style.backgroundColor='F9F9F9'"
				onmouseout="this.style.backgroundColor='white'" bgColor="#ffffff">
				<td height="25" align="center" nowrap class="kecttep_graytd"><%= new User().getName(userIDList[index])%></td>
				<td align="center" nowrap class="kecttep_graytd">
				<%if(changeUserIDList[index]==null || changeUserIDList[index].equals("")){%>
				초기화 <%}else{%> <%=us.getName(changeUserIDList[index])%> <%}%>
				</td>
				<td align="center" nowrap class="kecttep_graytd">
				<%if(changeUserIDList[index]==null || changeUserIDList[index].equals("")){%>
				초기화 <%}else{%> <%=changeUserDateList[index]%> <%}%>
				</td>
			</tr>
			<%}%>
		</table>
		</td>
	</tr>

	<tr>
		<td height="10"></td>
	</tr>

	<%if(count > 0){%>
	<tr align="center" valign="middle" style="padding-top: 3">
		<td class="kecttep_board" colspan="3"><!---- 페이지수 나오는 부분 시작 ---->
		<jsp:include page="/totsys/common/inc/board/page.jsp" flush="true">
			<jsp:param name="uri" value="<%= uri %>" />
			<jsp:param name="pageSize" value="<%= pageSize %>" />
			<jsp:param name="currentPage" value="<%= currentPage %>" />
			<jsp:param name="currentPageSetUp" value="<%= currentPageSetUp %>" />
		</jsp:include> <!---- 페이지수 나오는 부분 끝 ----></td>
	</tr>
	<%}else{%>
	<tr>
		<td colspan="3" height="25" align="center" class="kecttep_graytd">해당
		자료가 없습니다.</td>
	</tr>
	<%}%>
</table>
</body>
</html>
<%
}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{	
}
%>
