<%--
  - FileName   : conOutWarrPopup.jsp
  - Author(s)  : ok
  - Date       : 2014.06.26
  - Copyright  : Copyright (c) 2013 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();
    
    RowSet WarrGofficeComboList = storage.getRowSet("WarrGofficeComboList"); //보증기관 ComboList Data
    ValueObject WarrGubunNm = storage.getValueObject("WarrGubunNm");		//제증권구분
    ValueObject contOutWarr = storage.getValueObject("contOutWarr");		//보증정보
    ValueObject attfile = storage.getValueObject(params.get("warrGubun"));	//첨부파일
    
    String check1 = "";
    String check2 = "";
     if("1".equals(contOutWarr.get("GUAR_ONOFF_YN"))){
    	check1 = "checked";
    }else{
    	check2 = "checked";
    }
     
%>
<SCRIPT language="JavaScript">
	/*예약함수*/
	var sheet1;
	var sheet1Row;
	var sheet1PageNo = 1;
	var pageLastRowIndex = 1;
	var validationResult = false;
	var filterShow = false;
	
	function _onReady(){

		jQuery("#btnSave").click(function() {
		
			var f = document.form1;
			jQuery("#fevent").val("SAVE_DATA");
			//필수 입력항목 check
			if(requiredItemsCheck() == false){
				return;
			}
			//입력데이터 저장 
			if (confirm("저장 하시겠습니까?")) {
				
				//if(jQuery("#warrGubun").val() == "1"){	// 01:선급금보증 저장
					submitXmlRequest("/payment/outside/ContOutWarrPopup_form.screen", "SAVE_DATA", f, "SUCCESS");	
				//}
			}
		}); 
		
		jQuery("#btnSend").click(function() {
			
			var f = document.form1;
			jQuery("#fevent").val("REQ_DATA");
			//필수 입력항목 check
			if(requiredItemsCheck() == false){
				return;
			}
			
			//입력데이터 저장 
			if (confirm("선급금신청요청 하시겠습니까?")) {
				submitXmlRequest("/payment/outside/AdvencePayment_form.screen", "REQ_DATA", f, "SUCCESS");
			}
			
			
		});		

		jQuery("#btnClose").click(function() {
			
			alert();
			
			parent.callback_getContWarr();
			
		}); 
		
		pageinit();
		
	}
	
	//페이지 초기처리
	function pageinit(){

		inputDataSet();
		
	}
	
	//저장 및 선급금전송 시 필수항목 Check
	function requiredItemsCheck(){
		
		return true;
		
	}
	
	function doResult(resultObj) {
		try {
			
			if( resultObj.getRequestEvent() == "SAVE_DATA" ) {
				if( resultObj.getSuccess() ) {				
					alert("저장되었습니다.");		
					
					document.form1.isSubmit = false;
					/* jQuery("#btnSearch").click(); */
					
					searchData();
					
				}else {
					
					dlgErrorMsg(resultObj);
				}
				document.form1.isSubmit = false;
			}
			
			if( resultObj.getRequestEvent() == "GET_DATA" ) {
				
				if( resultObj.getSuccess() ) {
					
					var subContId = resultObj.getValueObject().get("SUB_CONT_ID");
					jQuery("#subContId").val(subContId);
					
				}else {
					dlgErrorMsg(resultObj);
				}
				document.form1.isSubmit = false;
			}
		}
		catch(errorObject) {
	        showErrorDlg("doResult()", errorObject);
		}
	}


	function doKeyPress() {
	
	    if( event.keyCode == 13 ) {
			doSearch(document.all.sheet1)
	    }
	}	

	function calendar(thisDayObj){
		dlgCalendar(thisDayObj);
	}		

	//첨부파일   
	function doAttachFile(obj,No) {
		
		if(obj.value == ''){
			alert("데이터를 저장 후, 파일을 첨부할 수가 있습니다.");
		}
		else if(obj.value != ''){
			var gubunStr = jQuery("#warrGubun").val();
			viewFileList(gubunStr, obj.value, document.form1.p_AttachFile1, "N", "N", "Y", "N");
		} 
	}
	
	function searchData(){
		
		var f = document.form1;
		jQuery("#fevent").val("GET_DATA");
		submitXmlRequest("/payment/outside/ContOutWarrPopup_form.screen", "GET_DATA", f, "VALUEOBJECT");
	}

	function inputDataSet(){
		
		if(jQuery("#warrGoffice option:selected").val() == "9"){	//기타

			jQuery("#warrGofficeEtc").attr("readonly",false);
			jQuery("#warrGofficeEtc").css({'background-color' : '#ffffff'});
			jQuery("#warrGofficeEtc").css({'border' : '1px solid #595a5a'});

		}else{

			jQuery("#warrGofficeEtc").attr("readonly",true);
			jQuery("#warrGofficeEtc").css({'background-color' : '#dedede'});
			jQuery("#warrGofficeEtc").css({'border' : '1px solid #bcbcbc'});
			
		}
		
	}
	
</SCRIPT>


<modular:search id="form1">
	<modular:key id="fevent" />
</modular:search>
<form id="form1" name="form1" method="post" modular:type="search">
<TABLE border="0" cellspacing="0" cellpadding="0" width="100%" height="100%">
<INPUT type="hidden" name="fevent" id="fevent" value="">

<INPUT type="hidden" name="warrContId" id="warrContId" value="<%=params.get("subContId") %>">		<!-- 보증증권 ID -->
<INPUT type="hidden" name="warrGubun" id="warrGubun" value="<%=params.get("warrGubun") %>">			<!-- 보증증권 구분 -->
<INPUT type="hidden" name="warrSeq" id="warrSeq" value="<%=params.get("warrSeq") %>">				<!-- 보증증권 일련번호 -->
<INPUT type="hidden" name="subContId" id="subContId" value="<%=contOutWarr.get("SUB_CONT_ID") %>">	

	<TR height="1">
		<TD>
			<TABLE class="screen_title_table" border="0">
				<TR height="25">
	   				<TD width="16" valign="middle"><IMG src="/img/buyer/button/subtitle_bullet.gif" ></TD>
   					<TD width="55%" class="screen_title_text">보증정보</TD>
   					<TD width="*" rowspan="3" class="search_button">      
      					<!-- 검색버튼 영역 : 시작 -->
           				<TABLE border="0" cellpadding="0" cellspacing="0" align="center">
           					<TR>
				                <TD>
				                	<DIV id="btnSave" class="button_style">
				                    	<TABLE border="0" cellpadding="0" cellspacing="0">
				                      		<TR> 
				                        		<TD class="button_left1"></TD>
				                        		<TD class="button_text1">저장&nbsp;</TD>
				                        		<TD class="button_right"></TD>
				                      		</TR>
				                    	</TABLE>
				                  	</DIV>
				                </TD>
               					<TD width="5"></TD>
				                <TD>
               						<DIV id="btnSend" class="button_style">
                   						<TABLE border="0" cellpadding="0" cellspacing="0">
                   							<TR> 
					                        	<TD class="button_left1"></TD>
					                        	<TD class="button_text1">보증서전송&nbsp;</TD>
					                        	<TD class="button_right"></TD>
                   							</TR>
                   						</TABLE>
               						</DIV>
               					</TD>
               					<TD width="5"></TD>
				                <TD>
               						<DIV id="btnClose" class="button_style">
                   						<TABLE border="0" cellpadding="0" cellspacing="0">
                   							<TR> 
					                        	<TD class="button_left1"></TD>
					                        	<TD class="button_text1">닫기&nbsp;</TD>
					                        	<TD class="button_right"></TD>
                   							</TR>
                   						</TABLE>
               						</DIV>
               					</TD>               					
           					</TR>
           				</TABLE>     
          				<!-- 검색버튼 영역 : 종료 -->  
   					</TD>
 				</TR>
			</TABLE>
		</TD>
	</TR>
	<!-- 데이터 상세 : 시작 -->
	<TR height="1">
		<TD>
			<!-- 보증정보 : 시작 -->
			<TABLE cellspacing="1" cellpadding="0" class="search_table" border="0" width="100%" height="100%">
				<colgroup>
					<col width="30%">
					<col width="35%">
					<col width="*">
				</colgroup>	
				<TR height="25"> 
					<TD class="insert_table_title required">&nbsp;발행방법</TD>
					<TD class="insert_table_data" colspan="2">
						<input type="radio" name="chk_info" value="1" onclick="" <%= check1 %> >온라인
						<input type="radio" name="chk_info" value="2" onclick="" <%= check2 %> >오프라인
					</TD>
				</TR>
				<TR height="25">
					<TD class="insert_table_title">&nbsp;발행구분</TD>
					<TD class="insert_table_data" colspan="2">&nbsp;<%= InputText.get("warrGubunNm", WarrGubunNm.get("DETAILNM") , 30, 30, "class=input_blank, readOnly=white, string, left, tabIndex=-1", "string") %></TD>
				</TR>
				<TR height="25">
					<TD class="insert_table_title required">&nbsp;보증기관명</TD>
					<TD class="insert_table_data" colspan="2">&nbsp;<%= HTMLMaker.getSelectTag(WarrGofficeComboList, "DETAILCD", "DETAILNM", "warrGoffice", "width:30%;height=18;' onChange='inputDataSet();", "", contOutWarr.get("WARR_GOFFICE")) %>&nbsp;
					<%= InputText.get("warrGofficeEtc", "", 40, 40, "string, left", "string") %>
					</TD>
				</TR>
				<TR height="25">
					<TD class="insert_table_title">&nbsp;변경구분</TD>
					<TD class="insert_table_data" colspan="2">&nbsp;<%= InputText.get("xxxxxxxx", "당초", 30, 30, "class=input_blank, readOnly=white, string, left, tabIndex=-1", "string") %></TD>
				</TR>
				<TR height="1">
					<TD>
						<TABLE border="0" cellspacing="0" cellpadding="0" class="search_data_div_height">
							<TR>
								<TD></TD>
							</TR>
						</TABLE>
					</TD>
				</TR>
				<TR height="25"> 
					<TD class="insert_table_title required">&nbsp;증권번호</TD>
					<TD class="insert_table_data" colspan="2">&nbsp;<%= InputText.get("warrWgon", contOutWarr.get("WARR_WGNO"), 50, 38, "string, left", "string") %></TD>
				</TR>
				<TR height="25">
					<TD class="insert_table_title required">&nbsp;보증기간</TD>
					<TD class="insert_table_data" colspan="2">&nbsp;
						<%= InputText.get("dateStart", Formatter.formatDate(contOutWarr.get("WARR_SDATE"), "-"), 40, 10, "Center, date, PerSize, readonly", "date", "") %>
						<A href="JavaScript:calendar('dateStart');"><IMG src="/img/buyer/btn/bt_calender.gif" alt="달력" border="0" align="absmiddle"></A>&nbsp;
							~
						&nbsp;<%= InputText.get("dateEnd", Formatter.formatDate(contOutWarr.get("WARR_EDATE"), "-"), 40, 10, "Center, date, PerSize, readonly", "date", "") %>
						<A href="JavaScript:calendar('dateEnd');"><IMG src="/img/buyer/btn/bt_calender.gif" alt="달력" border="0" align="absmiddle"></A>
					</TD>
				</TR>
				<TR height="25">
					<TD class="insert_table_title required">&nbsp;보증금액</TD>
					<TD class="insert_table_data" colspan="2">&nbsp;<%= InputText.get("warrWamt", Formatter.formatCurrency(contOutWarr.get("WARR_WAMT")), 36, 14, "class=input byteChk ,number, right", "number") %></TD>
				</TR>
				<TR height="25">
					<TD class="insert_table_title">&nbsp;발급일</TD>
					<TD class="insert_table_data" colspan="2">&nbsp;
						<%= InputText.get("paperDate", Formatter.formatDate(contOutWarr.get("PAPERDATE"), "-"), 40, 10, "Center, date, PerSize, readonly", "date", "") %>
						<A href="JavaScript:calendar('paperDate');"><IMG src="/img/buyer/btn/bt_calender.gif" alt="달력" border="0" align="absmiddle"></A>
					</TD>
				</TR>
				<TR height="25">
					<TD class="insert_table_title">&nbsp;첨부파일</TD>
					<TD class="insert_table_data" colspan="2">&nbsp;<TEXTAREA name="p_AttachFile1" id="p_AttachFile1" style="width:90%;height:90%;" rows="4" class="input" readOnly><%=attfile.get(params.get("warrGubun")) %></TEXTAREA>
						<IMG id='search_spot_button' onClick="doAttachFile(document.form1.subContId,1);" src='/img/buyer/button/bt_change.gif' border='0'  align="top" align='absmiddle' alt='[Attach File]' style='cursor:hand;'>
					</TD>
				</TR>				
			</TABLE>
		</TD>
	</TR>
</TABLE>
</FORM>