<%--
  - FileName   : prepayRequestList.jsp
  - Author(s)  : chs
  - Date       : 2021.03.17
  - Copyright  : Copyright (c) 2014 www.udapsoft.co.kr, Inc.
  - Description: 전자조달 템플릿 팝업
--%>

<%@ page contentType="text/html; charset=utf-8" %>
<%@ page import="com.udapsoft.waf.system.HandlerStorage" %>
<%@ page import="com.udapsoft.waf.common.ui.*" %>
<%@ page import="kr.co.hsnc.common.util.*"%>
<%@ page import="kr.co.hsnc.common.sql.*" %>
<%@ page import="kr.co.hsnc.common.util.Formatter"%>

<%@ include file="/jsp/work/taglib.jsp" %>
<jsp:useBean id="ctx" class="com.udapsoft.waf.system.context.SessionContext" scope="session" />
<%
	ctx.init(request, response);
	HandlerStorage storage = ctx.getHandlerStorage();
	ValueObject params = storage.getParams();
	ValueObject user = storage.getUser();
	String event = storage.getEvent();
	
	ValueObject vo = storage.getValueObject("templateVo");
	String templateHtml = vo.get("TEMPLATE_HTML").replace("</textarea>","</mod_textarea>");
	templateHtml = templateHtml.replace("&","&amp;");
    //String pageDiv = params.get("pageDiv");	//1:조달 2:포탈
    String template_cd = params.get("p_template_cd");	
    String seq = params.get("p_seq");	
    String job_div = params.get("p_job_div");	
    
%>
<SCRIPT language="JavaScript">
	
	function _onReady(){
		jQuery("#btnSave").click(function(){
		    submitXmlRequest("/test/ModStatusList_form.screen", "FORM_UPDATE", document.form1);
		});			
	
		jQuery("#btnClose").click(function(){
		    parent.SubetemplateClose();
		});		
	
		$("textarea").keydown(function(e) {

		    if(e.keyCode === 9) { // tab was pressed

			     // get caret position/selection
			     var start = this.selectionStart;
			     var end = this.selectionEnd;

			     var $this = $(this);
			     var value = $this.val();

			     // set textarea value to: text before caret + tab + text after caret
			     $this.val(value.substring(0, start)
			                    + "\t"
			                    + value.substring(end));

			     // put caret at right position again (add one for the tab)
			     this.selectionStart = this.selectionEnd = start + 1;

			     // prevent the focus lose
			     e.preventDefault();
			 }
		});
		
	}
	
	function pageinit(){
	}
	
	function doResult(resultObj) {
		try {
			if( resultObj.getRequestEvent() == "FORM_UPDATE") {
				if( resultObj.getSuccess() ) {
				    alert("저장되었습니다.");
				}
				else {
					dlgErrorMsg(resultObj);
				}
				document.form1.isSubmit = false;
			}
		}
		catch(errorObject) {
			showErrorDlg("doResult()", errorObject);
		}
	}
	
</SCRIPT>


<modular:search id="form1">
	<modular:key id="fevent" />
</modular:search>
<BODY>
<form id="form1" name="form1" method="post" modular:type="search">
	<INPUT type="hidden" name="fevent" id="fevent" value="">
	<%-- <INPUT type="hidden" name="pageDiv" id="pageDiv" value="<%=params.get("pageDiv")%>">	<!-- //1:조달 2:포탈  --> --%>
	<INPUT type="hidden" name="p_template_cd" id="template_cd" value="<%=params.get("p_template_cd")%>">
	<INPUT type="hidden" name="p_seq" id="seq" value="<%=params.get("p_seq")%>">
	<INPUT type="hidden" name="p_job_div" id="job_div" value="<%=params.get("p_job_div")%>">
	<INPUT type="hidden" name="userCorpId" id="userCorpId" value="<%=user.get("CORP_ID")%>">
	
	<!-- 검색조건 영역 : 시작 -->
	<table class="search-form-table" style="width: 100%">
	    <col width="10%">
		<col width="70%">
		<col width="20%">
		<TR height="25"> 
		    <th>제목</th>
		    <TD>
		        <input type="text" name="p_title" id="p_title" style="width: 86%;"  class="input byteChk ctrlTarget" value="<%=vo.get("TEMPLATE_NAME")%>"/>
		    </TD>
			<TD class="button" style="text-align: right;">      
				<!-- 검색버튼 영역 : 시작 -->
    			<span class="btnSearch center"><a href="javascript:void(0);" id="btnSave">저장</a></span>
    			<span class="btnSearch center"><a href="javascript:void(0);" id="btnClose">닫기</a></span>
    			&nbsp;&nbsp;&nbsp;
   			</TD>
  		</TR>
		<TR height="300"> 
			<TD colspan="3">
				<!-- vo.get("TEMPLATE_HTML").replace("</textarea>","</mod_textarea>") 로 문자를 변경 후 저장시에 java단에서 다시 변경하여 저장한다-->
				<textarea name="template" id="template" style="width:98%; height:450px; overflow-y:auto" class="input byteChk ctrlTarget"><%= templateHtml %></textarea> 
   			</TD>
  		</TR>
	</TABLE>
</FORM>
</body>
