<%
/**********************************************************************************
	프로그램명		: dept_view.jsp
	프로그램설명	:
	작 성 자			: 조용준
	작 성 일			: 04.0702
	최신변경일		:
***********************************************************************************/
%>
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ page import="javax.jdo.PersistenceManager"%>
<%@ page import="javax.jdo.Transaction"%>
<%@ page import="kr.co.kihyun.beans.entity.MDept"%>
<%@ page import="kr.co.kihyun.beans.entity.util.*"%>
<%@ page import="kr.co.kihyun.beans.user.HttpSSOLogin"%>
<%@ page import="kr.co.kihyun.text.html.ServletUtil"%>
<%@ page import="kr.co.kihyun.lang.Encoder"%>
<%@ page import="kr.co.kihyun.moumi.Moumi"%>
<%@ page import="kr.co.kihyun.lang.MString"
	import="kr.co.kihyun.lang.MLong" import="org.slf4j.Logger"
	import="org.slf4j.LoggerFactory"%>
<%@ include file="/totsys/common/inc/sec/secure.inc.jsp"%>
<%
	Logger LOG = LoggerFactory.getLogger(this.getClass());
	PersistenceManager pm = new MPersistenceManager(PMF.get().getPersistenceManager());
	Transaction tx = pm.currentTransaction();
	try{
        /***** user Login check *****************/
		if(!HttpSSOLogin.isLogin(request)){
			String connURL="parent.location='/totsys/login/login.jsp';";
			out.println(ServletUtil.getJavaScript(connURL));
			return;
		}

		/****** Parameter ******/
		String deptID = Encoder.toJava(request.getParameter("deptID"));
		String reload=request.getParameter("reload");
		if(reload==null) reload="no";
		/****** DEPT view data get ******/
		tx.begin();
		MDept deptView =(MDept) pm.getObjectById(MDept.class, deptID);
		String upperName = deptView.getUpperDept(pm) == null ? "" : deptView.getUpperDept(pm).getName();
		boolean selType = deptView.isDocUnit();
		Long priority = deptView.getPriority();
		String name = deptView.getName();
		String addr = deptView.getAddress();
		String phone = deptView.getPhone();
		String passcode = deptView.getPasscode();
		String recoImg = deptView.getRecoImg();

		String partID = deptView.getOrgan(pm) == null ? null : deptView.getOrgan(pm).getId();



		String organName=null;
		if(deptView.getOrgan(pm) == null) organName="";
		else organName=deptView.getOrgan(pm).getName();



		tx.rollback();

		if(recoImg==null)
			recoImg="";
		if(addr==null)
			addr="";
		if(phone==null)
			phone="";
%>
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<title><%=Moumi.getTitle()%></title>
<script type="text/javascript" src="/totsys/common/js/jquery-1.12.4.min.js"></script>
<script type="text/javascript" src="/totsys/common/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/totsys/common/js/jquery.hotkeys.js"></script>
<script type="text/javascript" src="/totsys/common/js/jquery.jstree.js"></script>
<link rel="stylesheet" href="/totsys/common/css/contentStyle.css" type="text/css">
<link rel="stylesheet" href="/totsys/common/css/basic.css" type="text/css">
<link rel="stylesheet" href="/totsys/common/css/text.css" type="text/css">
<link rel="stylesheet" href="/totsys/common/css/kecttep.css" type="text/css">
<link rel="stylesheet" href="/totsys/common/css/SquareButtons.css" type="text/css">
<script src="/totsys/common/js/rollover.js"></script>
<script>
	var reload='<%=reload%>';
	window.onload= function reload() {
		if(reload=='yes') { parent.treeReload(); }
	};
</script>
<style>
td {
	padding: 1 2 1 2;
}
</style>
</head>

<body class="over_hidden">
<table style="width: 520px;">
	<jsp:include page="/totsys/common/inc/sysadm/top/top.jsp" flush="true" />
	<tr>
		<td style="width: 0"></td>
		<td style="vertical-align: top;">
		<table>
			 <tr class="toolbar">
		<td style="text-align: right;">
		<table>
			<tr>
                <td >부서정보
                </td>
			</tr>
		</table>
		</td>
	</tr>

			<tr>
				<td style="height: 31px; vertical-align: top;">
				<table class="kecttep_list_table">
					<!--  부서 ID  -->
					<tr>
						<td class="kecttep_tdmenu_middle" style="padding-left: 10px; width: 120px; height: 31px;">
							<img alt="글머리" src="/totsys/common/images/icon.gif">&nbsp;&nbsp;<b>부서코드</b>
						</td>
						<td class="kecttep_last_graytd" style="padding-left: 10px;"><%=deptID%>&nbsp;</td>
					</tr>
					<!--  부서명  -->
					<tr>
						<td class="kecttep_tdmenu_middle" style="padding-left: 10px; height: 31px;">
						<img alt="글머리" src="/totsys/common/images/icon.gif">&nbsp;&nbsp;<b>부서명</b></td>
						<td class="kecttep_last_graytd" style="padding-left: 10px;"><%=name%>&nbsp;</td>
					</tr>
					<!-- 부서전화번호 -->
					<tr>
						<td class="kecttep_tdmenu_middle" style="padding-left: 10px; height: 31px;">
							<img alt="글머리" src="/totsys/common/images/icon.gif">&nbsp;&nbsp;<b>전화번호</b>
						</td>
						<td class="kecttep_last_graytd" style="padding-left: 10px;"><%=phone%>&nbsp;</td>
					</tr>
					<!-- 부서주소 -->
					<tr>
						<td class="kecttep_tdmenu_middle" style="padding-left: 10px; height: 31px;">
						<img alt="글머리" src="/totsys/common/images/icon.gif">&nbsp;&nbsp;<b>주소</b></td>
						<td class="kecttep_last_graytd" style="padding-left: 10px;">
						<%	out.println(MString.checkNull(MString.replaceString(addr,"\r\n","<br>")));	%>&nbsp;
						</td>
					</tr>
					<!-- 상위부서 -->
					<tr>
						<td class="kecttep_tdmenu" style="padding-left: 10px; height: 31px;">
						<img alt="글머리" src="/totsys/common/images/icon.gif">&nbsp;&nbsp;<b>상위부서</b></td>
						<td class="kecttep_last_graytd_bottom" style="padding-left: 10px;"><%= upperName%>&nbsp;</td>
					</tr>
					<!-- 기관명 -->
					<!--
									<tr>
										<td height="31" class="kecttep_tdmenu"><img src="/totsys/common/images/icon.gif" align="middle">&nbsp;&nbsp;<b>카테고리</b></td>
										<td class="kecttep_last_graytd" style="padding-left: 10;"><%=organName%>&nbsp;</td>
									</tr>
									-->
					<!-- 문서수발신단위 -->
					<!--//<tr>
						<td height="31" class="kecttep_tdmenu"><img
							src="/totsys/common/images/icon.gif" align="middle">&nbsp;&nbsp;<b>문서수발신단위</b></td>
						<td class="kecttep_last_graytd" style="padding-left: 5;"><input disabled
							type="checkbox" <%=selType ? " checked=\"yes\"" : ""%> />&nbsp;</td>
					</tr>//-->
					<!-- 정렬순위 -->
					<!--//<tr>
						<td height="31" class="kecttep_tdmenu"><img
							src="/totsys/common/images/icon.gif" align="middle">&nbsp;&nbsp;<b>정렬순위</b></td>
						<td class="kecttep_last_graytd" style="padding-left: 10;"><%= priority %>&nbsp;</td>
					</tr>//-->
				</table>
				</td>
			</tr>
		</table>
		</td>
		<td style="width: 10px;"></td>
	</tr>
	<!-- top menu start -->
	<%@ include file="/totsys/common/inc/buttom/buttom.jsp"%>
	<!-- top menu end -->
</table>

</BODY>
</HTML>
<%
	}catch(Exception ex){
                //38.오류메세지를 통한 정보 노출(getMessage)_CWE-209 : Update by YOUNGJUN,CHO
		ex.printStackTrace();
		//out.println(ex);
		//out.println("<html><body style='overflow=auto' bgcolor='white'><h1>Can't contact servlet runner</h1><br><br> Message : "+ex.getMessage()+"</body></html>");
		//out.println("<META HTTP-EQUIV='refresh' CONTENT='0.1 URL=/error/exception.jsp'>");
                //================================================
	}finally{

		if(tx.isActive())
			tx.rollback();
		pm.close();
	}
%>
