<%--
  - FileName   : prepayRequestList.jsp
  - Author(s)  : chj
  - Date       : 2014.07.28
  - 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("emailVo");
    String pageDiv = params.get("pageDiv");	//1:조달 2:포탈
    
%>
<SCRIPT language="JavaScript">
	
	function _onReady(){
		jQuery("#btnSave").click(function(){
		    var f = document.form1;
		    submitXmlRequest("/supplier/purchase/PurSupplierEmail_form.screen", "FORM_UPDATE", f);
		});		

		jQuery("#btnTest").click(function(){
		    var f = document.form1;
		    submitXmlRequest("/supplier/purchase/PurSupplierEmail_form.screen", "FORM_TEST", f);
		});		
	
		jQuery("#btnClose").click(function(){
		    parent.SubemailClose();
		});		
	
		$("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;
			}else if(resultObj.getRequestEvent() == "FORM_TEST"){
			    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="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("title")%>"/>
		    </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="btnTest">테스트</a></span>
    			<span class="btnSearch center"><a href="javascript:void(0);" id="btnClose">닫기</a></span>
    			&nbsp;&nbsp;&nbsp;
   			</TD>
  		</TR>
		<TR height="200"> 
			<TD colspan="3">     
				<textarea name="email" id="email" style="width:98%; height:200px; overflow-y:auto" class="input byteChk ctrlTarget"><%=vo.get("SEND_EMAIL").replace("&","&amp;") %></textarea> 
   			</TD>
  		</TR>
	</TABLE>
</FORM>
</body>
