
<%
/************************************************************@@
  * Program Name	: doc_regist.jsp
	* Description	: /집계자/내문서함/등록함/문서 등록
	* Author		: 기현테크
	* Create Date	: 2010.11.25
	* History		:			:
@@************************************************************/
%>
<%@ page contentType="text/html; charset=UTF-8"
	import="java.net.URLEncoder" import="java.net.URLDecoder"
	import="kr.co.kihyun.beans.user.HttpSSOLogin"
	import="kr.co.kihyun.beans.entity.TotDocAppendType"
	import="kr.co.kihyun.lang.Encoder" import="kr.co.kihyun.lang.MString"
	import="kr.co.kihyun.lang.MInteger" import="kr.co.kihyun.moumi.MoumiConfig"
	import="kr.co.kihyun.moumi.doc.MDoc" import="kr.co.kihyun.util.MDate"
	import="kr.co.kihyun.text.html.ServletUtil"
	import="kr.co.kihyun.lang.StringConverter"
	import="kr.co.kihyun.text.html.HtmlUtil"
	import="kr.co.kihyun.text.html.TagFilter"
	import="org.apache.commons.lang.StringEscapeUtils"%>
<%@page import="kr.co.kihyun.beans.entity.TotDoc"%>
<%@page import="kr.co.kihyun.beans.entity.TotDocType"%>

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

<%
	try {
		/********** session내의 userId **********/
		String deptIDs = HttpSSOLogin.getDeptID(request);
		String usID = HttpSSOLogin.getLoginID(request);
		int sysAuth = HttpSSOLogin.getSysAuth(request);

		if (sysAuth == MoumiConfig.SUB_TOTPER && MoumiConfig.isMonitor()) {
			String connURL = "history.go(-1);";
			out.println(ServletUtil
					.alert(MoumiConfig.getMessageBundle().getString("moumi.message.popup.registAuth")));
			out.println(ServletUtil.getJavaScript(connURL));
			return;
		}

		/************ top value ************/
		String dirPath = URLEncoder
				.encode("<a href=\"/totsys/totper/mydocbox/index.html\" class=\"d11_blue\">"+MoumiConfig.getMessageBundle().getString("moumi.message.tot_doc.myDoc")+"</a> &gt; <a href=\"/totsys/totper/mydocbox/formbox/doc_list.jsp\" class=\"d11_blue\">"+MoumiConfig.getMessageBundle().getString("moumi.message.tot_doc.formBox")+"</a>");

		/************ Parameter values ************/
		String strPage = clearXSS(request.getParameter("strPage"), "");
		String findOption = clearXSS(
				request.getParameter("findOption"), "");
		String findWord = clearXSS(Encoder.toJava(request
				.getParameter("findWord")), "");
		String reuseDocID = "";
		reuseDocID = clearXSS(MString.checkNull(request
				.getParameter("reuseDocID")), "");

		/**************** 추가 **************/
		String docID = clearXSS(request.getParameter("docID"), "");
		String choice = clearXSS(request.getParameter("choice"), "");
		//String deptIDs = clearXSS(Encoder.toJava(MString.checkNull(request.getParameter("deptIDs"))),"");
		String deptNames = clearXSS(Encoder.toJava(MString
				.checkNull(request.getParameter("deptNames"))), "");
		String userIDs = clearXSS(Encoder.toJava(MString
				.checkNull(request.getParameter("userIDs"))), "");
		String userNames = clearXSS(Encoder.toJava(MString
				.checkNull(request.getParameter("userNames"))), "");
		String docName = clearXSS(Encoder.toJava(MString
				.checkNull(request.getParameter("docName"))), "");
		String stDate = clearXSS(request.getParameter("stDate"), "");
		String edDate = clearXSS(request.getParameter("edDate"), "");
		String accAuth = clearXSS(request.getParameter("accAuth"), "1");
		String repDocID = clearXSS(request.getParameter("repDocID"), "");
		String docGroupID = clearXSS(
				request.getParameter("docGroupID"), "");
		String isFromFormBox = clearXSS(request
				.getParameter("isFromFormBox"), "");
		String tableCount = clearXSS(
				request.getParameter("tableCount"), "");
		String isDynaTable = clearXSS(request
				.getParameter("isDynaTable"), "");
		String mode = clearXSS(request.getParameter("mode"), "");
		String tableDefines = clearXSS(request
				.getParameter("tableDefines"), "");
		String itemNames = clearXSS(Encoder.toJava(request
				.getParameter("itemNames")), "");
		String tableNums = clearXSS(Encoder.toJava(request
				.getParameter("tableNums")), "");
		String colNums = clearXSS(Encoder.toJava(request
				.getParameter("colNums")), "");
		String rowNums = clearXSS(Encoder.toJava(request
				.getParameter("rowNums")), "");
		String itemSizes = clearXSS(Encoder.toJava(request
				.getParameter("itemSizes")), "");
		String itemDescs = clearXSS(Encoder.toJava(request
				.getParameter("itemDescs")), "");
		String itemExprs = clearXSS(Encoder.toJava(request
				.getParameter("itemExprs")), "");
		String itemTypes = clearXSS(Encoder.toJava(request
				.getParameter("itemTypes")), "");
		String docForm = clearXSS(request.getParameter("docForm"), "");

		String backDash = clearXSS(request.getParameter("backDash"), "");
		if (backDash.equals("back")) {
			if ((String) session.getAttribute("docForm") == ""
					|| (String) session.getAttribute("docForm") == null) {
			} else {
				docForm = (String) session.getAttribute("docForm");
			}
		}
		/********** 현재 년, 월, 일 **********/
		MDate date = new MDate();

		String stTime;
		String edTime = "23";

		if (stDate.equals("")) {
			stDate = date.getTotDocDate();
			stTime = date.getHour();
		} else {
			String[] stD = stDate.split(" ");
			stDate = stD[0];
			stTime = stD[1];
		}

		if (edDate.equals("")) {
			edDate = date.getTotDocDate();
		} else {
			String[] edD = edDate.split(" ");
			edDate = edD[0];
			edTime = edD[1];
		}
%>

<HTML>
<HEAD>
<TITLE><%=MoumiConfig.getTitle()%></TITLE>
<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 src="/totsys/common/js/util.js"></script>
<script src="/totsys/common/js/calendar.js"></script>
<script src="/totsys/common/js/drag.js"></script>
<script src="/totsys/common/js/date.js"></script>
<script src="/totsys/common/js/checkNum.js"></script>
<SCRIPT src='/totsys/common/js/editor.js'></SCRIPT>
<SCRIPT language=javascript>
			var isEdited=false;
			<%
			if (backDash.equals("back")) {
				if (!MString.isNull((String) session.getAttribute("docForm"))) {
			%>
			isEdited = true;
			<%
				}
			}
			%>
			function setValue(){
				if("<%=docName%>" != ""){
					docForm.docName.value="<%=docName%>";
					docForm.accAuth["<%=accAuth%>"].checked = true;
				}else{
					init();
					EditCtrl.document.body.innerHTML = '<center><%=MoumiConfig.getMessageBundle().getString("moumi.message.tot_doc.formCopy")%></center>';
				}
			}

			function openWin(theURL,features) {
				var farwindow = null;
				 farwindow = window.open(theURL,'farwindow',features);
				 farwindow.focus();
			}

			function browseFile() {
				document.write('<input type="file" name = "upFile" >');
			}

			function browseOld() {
				document.write('<input type="file" name = "upFile" >');
			}

			function formSubmit(){
				var fn = docForm.formFileName.value;
				docForm.copyForm.value = EditCtrl.document.body.innerHTML;

				if (docForm.docName.value == '') {
					alert('<%=MoumiConfig.getMessageBundle().getString("moumi.message.popup.dataNameCheck")%>');
					docForm.docName.focus();
					return;
				}else if (containsChars(docForm.docName,'￦/?"<>|!,*&^%$#@~;')) {
					alert('<%=MoumiConfig.getMessageBundle().getString("moumi.message.popup.dataNameSymboleCheck")%>');
					docForm.docName.focus();
					return;
				}else if (docForm.accAuth[0].checked == false && docForm.accAuth[1].checked == false && docForm.accAuth[2].checked == false) {
					alert('<%=MoumiConfig.getMessageBundle().getString("moumi.message.popup.docAuth")%>');
					return;
				}else{
					docForm.submit();
				}
			}

			function isDateTrue(stDate, stTime, edDate, edTime){
				if(stDate < edDate){
					return false;
				}else	if(stDate == edDate){
					if(stTime < edTime) return false;
				}

				return true;
			}

			function containsChars(input,chars) {
				for (var inx = 0; inx < input.value.length; inx++) {
					if (chars.indexOf(input.value.charAt(inx)) != -1)
						return true;
				}
				return false;
			}

			function AllDataRemove(){
				docForm.deptNames.value='';
			}

			function ShowDocPool(accAuth){
				document.all.type1.style.display="none";
				//document.all.type2.style.display="inline";
				document.all.type3.style.display="none";
				window.open('./popup_doc_list.jsp?accAuth='+accAuth,'makepoll','width=700,height=600,scrollbars=yes,resizable=yes');
			}

			function ShowFile(){
				document.all.type3.style.display="none";
				//document.all.type2.style.display="none";
				document.all.type1.style.display="inline";
			}

			function ShowCopy(){
				document.all.type1.style.display="none";
				//document.all.type2.style.display="none";
				document.all.type3.style.display="inline";
				//window.open('/totsys/common/web/documents/tot_doc/popup_copy_form.jsp','makecopy','width=950,height=595,scrollbars=no,resizable=no');
			}

			function deptSelectOpen() {
				var height = screen.height;
				var width = screen.width;
				var leftpos = width / 2 - 350;
				var toppos = height / 2 - 300;

				var urlname = "/totsys/common/web/report_dept/popup_dept_list.jsp";
				post= window.open(urlname, "post","width=650, height=605, toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,left=" + leftpos + ",top=" + toppos);
				post.focus();
			}

			function viewNote(){
				var width = 600;
				var height = 410;
				var leftpos = (screen.width - width) / 2; 
				var toppos = (screen.height - height) / 2; 	
				window.open("/totsys/common/web/note/popup_manual.jsp","","width="+width+", height="+height+", toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,left= "+ leftpos +" ,top= "+ toppos);
			}
		</SCRIPT>
</HEAD>

<body style='' BGCOLOR="#FFFFFF" LEFTMARGIN="0" TOPMARGIN="0"
	MARGINWIDTH="0" MARGINHEIGHT="0"
	onload="init();setValue();docForm.docName.focus();">
<div id="SetWin" style="position: absolute; visibility: hidden; width: 100px; height: 100px; background: silver; border: 1px solid #333333; line-height: 1.4em; padding: 3px 3px"></div>
<table width="100%" height="70" border="0" cellpadding="0"
	cellspacing="0">
	<!------------------------------- top menu start ------------------------------->
	<jsp:include page="/totsys/common/inc/totper/top/top.jsp" flush="true">
		<jsp:param name="dirPath" value="<%= dirPath %>" />
	</jsp:include>
	<!------------------------------- top menu end ------------------------------->
	<tr>
		<td nowrap width="0"></td>
		<td valign="top">
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
			<jsp:include page="/totsys/common/inc/title/title.jsp" flush="true" />
			<tr>
				<td height="1"></td>
			</tr>
			<tr>
				<td height="31" valign="top">
					<form name="docForm"
						action="/servlet/kr.co.kihyun.beans.totsys.doc.HttpFormReader"
						method=post encType="multipart/form-data"><input
						type="hidden" name="docGroupID" value="<%=MDoc.FORM_DOC%>">
				<table width="100%" border="0" cellspacing="0" cellpadding="0">
					<tr nowrap height="10">
						<td height="10"></td>
						<td></td>
						<td></td>
						<td></td>
					</tr>

					<input type="hidden" name="copyForm"> <input type="hidden"
						name="userID" value="usID"> <input type="hidden"
						name="repDocID" value="repDocID"> <input type="hidden"
						name="deptIDs" value="<%=deptIDs%>"> <input name="stDate"
						type="hidden" value="<%=stDate%>"> <input name="stTime"
						type="hidden" value="<%=stTime.substring(0, 2)%>"> <input
						name="edDate" type="hidden" value="<%=edDate%>"> <input
						name="edTime" type="hidden" value="<%=edTime.substring(0, 2)%>">
					<!--세미타이틀-->
					<tr>
						<td colspan="4">
						<table border="0" width="100%" cellpadding="0" cellspacing="0">
							<tr>
								<td style="width: 14"><img
									src="/totsys/common/images/ico_1.gif"></td>
								<td class="kecttep_title" style="padding-left: 5" align="left"
									width="100%"><%=TotDocType.FORM_DOC %><%=MoumiConfig.getMessageBundle().getString("moumi.message.tot_doc.registrition")%></td>
								<td>&nbsp;</td>
								<td>&nbsp;</td>
							</tr>
							<tr>
								<td height="3"></td>
							</tr>
						</table>
						</td>
					</tr>

					<tr>
						<td colspan="4">
						<table border="1px" bordercolor="#e3e3e3"
							class="kecttep_list_table" width="100%" cellpadding="0"
							cellspacing="0">
							<tr>
								<!---- 양식명 ---->
								<td width="120" nowrap class="kecttep_tdmenu"><img
									src="/totsys/common/images/reg_icon.gif" align="absmiddle"><%=TotDocType.FORM_DOC %><%=MoumiConfig.getMessageBundle().getString("moumi.message.tot_doc.name")%></td>
								<td class="kecttep_top_graytd" width="300" nowrap
									style="padding-left: 15;"><input name="docName"
									type="text" class="inputtxt" STYLE="width: 98%"
									value="<%=docName%>"></td>
								<!---- 양식권한 ---->
								<td width="120" nowrap class="kecttep_tdmenu"><img
									src="/totsys/common/images/reg_icon.gif" align="absmiddle"><%=MoumiConfig.getMessageBundle().getString("moumi.message.tot_doc.doc")%><%=MoumiConfig.getMessageBundle().getString("moumi.message.tot_doc.public")%></td>
								<td class="kecttep_top_graytd" style="padding-left: 15;">
								<input name="accAuth" value="1" type="radio"<%= "1".equals(accAuth) ? " checked" : "" %>><%=MoumiConfig.getMessageBundle().getString("moumi.message.tot_doc.devision")%>&nbsp;
								<input name="accAuth" value="0" type="radio"<%= "0".equals(accAuth) ? " checked" : "" %>><%=MoumiConfig.getMessageBundle().getString("moumi.message.tot_doc.personal")%>&nbsp;
								<input name="accAuth" value="2" type="radio"<%= "2".equals(accAuth) ? " checked" : "" %>><%=MoumiConfig.getMessageBundle().getString("moumi.message.tot_doc.coporation")%>&nbsp;
								</td>
							</tr>
							<!--<tr>
											<!---- 양식파일 ----
											<td width="120" nowrap class="kecttep_tdmenu"><img src="/totsys/common/images/reg_icon.gif" align="absmiddle" ><%=MoumiConfig.getMessageBundle().getString("moumi.message.tot_doc.formDoc")%><%=MoumiConfig.getMessageBundle().getString("moumi.message.tot_doc.form")%></td>
											<td width="300" nowrap style="padding-left:15;"  >
												<!--input type="radio" name="appendType" value="2" onclick="ShowFile();" ><%=MoumiConfig.getMessageBundle().getString("moumi.message.tot_doc.new")%><%=MoumiConfig.getMessageBundle().getString("moumi.message.tot_doc.formDoc")%>
												<input type="radio" name="appendType" value="1" onclick="ShowCopy();" checked><%=MoumiConfig.getMessageBundle().getString("moumi.message.tot_doc.copy")%><%=MoumiConfig.getMessageBundle().getString("moumi.message.tot_doc.new")%><%=MoumiConfig.getMessageBundle().getString("moumi.message.tot_doc.formDoc")%>
											</td>
											<!---- 기타 ----
											<td width="120" nowrap class="kecttep_tdmenu"><img src="/totsys/common/images/reg_icon.gif" align="absmiddle" ><%=MoumiConfig.getMessageBundle().getString("moumi.message.tot_doc.formDoc")%><%=MoumiConfig.getMessageBundle().getString("moumi.message.tot_doc.file")%> <%=MoumiConfig.getMessageBundle().getString("moumi.message.tot_doc.path")%></td>
											<td style="padding-left:15;">
												<DIV id="type3" style="POSITION: relative; padding-top:5" align="absmiddle"><%=MoumiConfig.getMessageBundle().getString("moumi.message.tot_doc.newCopyForm")%></DIV>
												<DIV id="type1" style="DISPLAY: none; POSITION: relative" align="absmiddle"><input type="file" style="width:98%" name="formFileName" class="inputtxt"></DIV>
											</td>
										</tr>-->

							<input type="hidden" name="appendType"
								value="<%= TotDocAppendType.COPY %>">
							<input type="hidden" name="formFileName">

							<tr>
								<td colspan="4">
								<table width="100%" border=1 cellpadding=0 cellspacing=0>
									<tr>
										<td></td>
									</tr>
									<tr>
										<td height="250"><iframe id='i_fontcolor'
											style='background-color: #ffffff; border: 1px double #BFBFBF; cursor: hand; position: absolute; visibility: hidden;'
											scrolling=no frameborder=0 width=120 height=120></iframe> <iframe
											id='i_backcolor'
											style='background-color: #ffffff; border: 1px double #BFBFBF; cursor: hand; position: absolute; visibility: hidden;'
											scrolling=no frameborder=0 width=120 height=120></iframe> <iframe
											id='i_image'
											style='color: #000000; background-color: #efefef; border: 1px double #BFBFBF; cursor: default; position: absolute; visibility: hidden;'
											scrolling=no frameborder=0 width=325 height=85></iframe> <iframe
											id='i_link'
											style='color: #000000; background-color: #efefef; border: 1px double #BFBFBF; cursor: default; position: absolute; visibility: hidden;'
											scrolling=no frameborder=0 width=325 height=70></iframe> <iframe
											id='i_emoticon'
											style='background-color: #efefef; border: 1px double #BFBFBF; cursor: hand; position: absolute; visibility: hidden;'
											scrolling=no frameborder=0 width=125 height=125></iframe>
										<div id='editctrl' style='display: show; width: auto; height: auto;'><iframe
											name='EditCtrl' width='100%' height='100%' scrolling='YES'
											onfocus='if(!isEdited)EditCtrl.document.body.innerHTML = ""; isEdited=true;'
											frameborder="0"></iframe></div>
										</td>
									</tr>
								</table>
								</td>
							</tr>

							<!---- 양식등록 끝 ---->
						</table>
						</td>
					</tr>

					<!----  버튼 (이전단계, 다음단계)시작 ---->
					<tr>
						<td colspan="4" align="center">
						<table border="0" cellpadding="0" cellspacing="0">
							<tr>
								<!--
													<td><a href="#" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('bt_pre','','/totsys/common/images/bt_pre.gif',1)" onclick="history.go(-1);"><img src="/totsys/common/images/bt_pre.gif" name="bt_pre" border="0"></a></td>
													<td width="5"></td>
													-->
								<td><a href="#" onMouseOut="MM_swapImgRestore()"
									onMouseOver="MM_swapImage('bt_next','','/totsys/common/images/bt_next.gif',1)"
									onclick="formSubmit();"><img
									src="/totsys/common/images/bt_next.gif" name="bt_next"
									border="0"></a></td>
							</tr>
						</table>
						</td>
					</tr>
					<!---- 버튼 (이전단계, 다음단계) 끝 ---->
				</table>
				</form>
				</td>
			</tr>


		</table>
		</td>
		<td nowrap width="10"></td>
	</tr>
	<!------------------------------- top menu start ------------------------------->
	<%@ include file="/totsys/common/inc/buttom/buttom.jsp"%>
	<!------------------------------- top menu end ------------------------------->
</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 {
		/********** session내의 doc info reset **********/
		MDoc.initSession(session);
	}
%>
