<%--
  - Author(s)  : Kim Myung HO
  - Date       : 2014.08.11
  - Description: 계약 결과 작성
  --%>
  
<%@page import="java.sql.Clob"%>
<%@ page contentType="text/html; charset=utf-8" %>
<%@ page import="com.udapsoft.waf.system.HandlerStorage" %>
<%@ page import="com.udapsoft.waf.common.ui.*" %>
<%@ page import="com.udapsoft.waf.common.util.*" %>
<%@ page import="kr.co.hsnc.common.util.*"%>
<%@ page import="kr.co.hsnc.common.sql.*" %>
<%@ page import="kr.co.hsnc.common.config.WAFConfig" %>
<%@ include file="/jsp/work/taglib.jsp" %>
<%@ page import="kr.co.hsnc.common.util.Formatter"%>
<%@page import="java.net.URLEncoder"%>
<%@ page import="kr.co.udapsoft.ebid.buyer.common.file.FileManager"%>

<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();
   // RowSet CorpRowSet = storage.getRowSet("CorpRowSet");
    ValueObject ContInfo = storage.getValueObject("ContInfo");
    
    String FILE_GB =   (String) storage.get("FILE_GB");
	String DEMANDED_ID =   (String) storage.get("DEMANDED_ID");

    /*계약서식 정보 */
    RowSet template = storage.getRowSet("template");

    /*계약서식 FILE */
	RowSet autofile_list = storage.getRowSet("AUTOFILE_LIST");  
    
    /*보증 정보 LIst */
	RowSet warrList = storage.getRowSet("warrList");        
    
	/*인지세 구분*/
    RowSet stampList = storage.getRowSet("stampRowSet");
	
%>
<LINK href="/css/cont/cont_style.css" rel="stylesheet" type="text/css">
<script language="javascript" src="/js/cont/cont_util.js"></script>
<script language="javascript" src="/js/cont/lib.validate.js"></script>
<SCRIPT language="JavaScript">
/*예약함수*/
var sheet1;
var sheet1Row;
var sheet1PageNo = 1;
var pageLastRowIndex = 1;
var validationResult = false;
var filterShow = false;

	function _onReady(){
		/* STAMP_DUTY, PROMISE_DOC 인클루드 페이지 기능 */
		gridInit2(sheet2);
		gridInit3(sheet3);
		doSearchStamp();
		doSearchPromise();
		
		if(!(jQuery("#STATUS_CD").val() == '20' || jQuery("#STATUS_CD").val() == '30' || jQuery("#STATUS_CD").val() == '50')){
			jQuery("#p_issue_gb").attr("disabled",false);
			jQuery("#p_promise_gb").attr("disabled",false);
			
			if(jQuery("#p_issue_gb").val()=="00"||jQuery("#p_issue_gb").val()==""){
				jQuery("#btnAdd").hide();
				jQuery("#btnSaveStamp").hide();	
			}else{
				jQuery("#btnAdd").show();
				jQuery("#btnSaveStamp").show();	
			}
			
			if(jQuery("#p_promise_gb").val()=="00"||jQuery("#p_promise_gb").val()==""){
				//jQuery("#btnPromiseAdd").hide();
				jQuery("#btnSavePromise").hide();	
			}else{
				//jQuery("#btnPromiseAdd").show();
				jQuery("#btnSavePromise").show();	
			}
		}else{
			jQuery("#p_issue_gb").attr("disabled",true);
			jQuery("#p_promise_gb").attr("disabled",true);
			
			if(jQuery("#p_issue_gb").val()=="00"||jQuery("#p_issue_gb").val()==""||jQuery("#STATUS_CD").val() == '50'){
				jQuery("#btnAdd").hide();
				jQuery("#btnSaveStamp").hide();	
			}else{
				jQuery("#btnAdd").show();
				jQuery("#btnSaveStamp").show();	
			}
			
			if(jQuery("#p_promise_gb").val()=="00"||jQuery("#p_promise_gb").val()==""||jQuery("#STATUS_CD").val() == '50'){
				//jQuery("#btnPromiseAdd").hide();
				jQuery("#btnSavePromise").hide();	
			}else{
				//jQuery("#btnPromiseAdd").show();
				jQuery("#btnSavePromise").show();	
			}
		}
		 
		checkAuthority();
		
		if(('<%=params.get("TEMPLATE_NAME") %>')=="이전 계약"){
			jQuery("#search_spot_button").show();
		}
		 
		
		jQuery("#btnInsur").click(function(){
			var f = document.form1;
			jQuery("#fevent").val("SAVE_INSUR");
			submitXmlRequest("/cont/outside/ContResult_form.screen", "SAVE_INSUR", f);
		});
		
		jQuery("#btnChange").click(function() {
			if (confirm("변경 계약을 진행 하시겠습니까?")){
				var f = document.form1;
				jQuery("#fevent").val("CHANGE_CONT");
				submitXmlRequest("/cont/outside/ContResult_form.screen", "CHANGE_CONT", f);
			}
		});
		jQuery("#btnSavePayItem").click(function() {
			if (confirm("분개유형을 저장 하시겠습니까?")){
				var f = document.form1;
				jQuery("#fevent").val("SAVE_PAYITEM");
				submitXmlRequest("/cont/outside/ContResult_form.screen", "SAVE_PAYITEM", f);
			}
		});
		//2017.05.16 업체담당자 HP, email 수정 
		jQuery("#btnChgSuppInfo").click(function() {
			if (confirm("담당자 정보를 수정 하시겠습니까?")){
				var f = document.form1;
				jQuery("#fevent").val("CHG_SUPP_INFO");
				submitXmlRequest("/cont/outside/ContResult_form.screen", "CHG_SUPP_INFO", f);
			}
		});
		
		//외주내역 팝업 2018.10.18
		jQuery("#btnItem").click(function() {			
			var win_id = "ItemPop";			
  
			var link = "/cont/outside/ContItemPopup.screen";
			link += "?pop_win_id="+win_id+"&mod_no="+jQuery("#MOD_NO").val() + "&sub_cont_mod_id="+jQuery("#SUB_CONT_MOD_ID").val()+"&digit="+"<%=ContInfo.get("SOSUNUM")%>"+"&edit_yn=N";
			fLayerPop(win_id, link, 950,500, '','', 'NO');
		});	
	} 

	//자동로그인 기능
	function f_gologin(login_id,login_pw){
		var f = document.form1;
		if('<%= user.get("ACCT_TYPE_CODE")%>' != "ADMIN"){
			dlgAlert("User who logged in as administrator only can do automatic log-in.");
			return;
		}
	
		f.login_id.value = login_id;
		f.login_pw.value = login_pw;
	
		if( !submitXmlRequest("/sign_on_check", "", document.form1) ) {
			alert("Log-in is being processed.");
		};
	
	}

	function goListProc(){
		 var f = document.form1;
		f.fevent.value ="";
	    f.action = "/cont/outside/ContResultList.screen";
	    f.target = "_self";
	    f.submit();
	}
	
	function doResult(resultObj) {
		try {
			if( resultObj.getRequestEvent() == "CHANGE_CONT") {
				if( resultObj.getSuccess() ) {
					alert("변경 계약이 처리 되었습니다.\n\n변경계약 목록에서 계약서를 작성 해 주시기 바랍니다.")
					location.href="/cont/outside/ContTargetList.screen?ChgCont=Y";
				} else {
					dlgErrorMsg(resultObj);
				}
			}
			if( resultObj.getRequestEvent() == "SAVE_PAYITEM") {
				if( resultObj.getSuccess() ) {
					alert("분개유형이 저장 되었습니다.")
					location.reload();
				} else {
					dlgErrorMsg(resultObj);
				}
			}
			if( resultObj.getRequestEvent() == "CHG_SUPP_INFO") {
				if( resultObj.getSuccess() ) {
					alert("담당자정보가 수정 되었습니다.")
					location.reload();
				} else {
					dlgErrorMsg(resultObj);
				}
			}
			if( resultObj.getRequestEvent() == "SAVE_INSUR"){
				if(resultObj.getSuccess()){
					var f = document.form1;
					f.fevent.value ="";
				    f.action = "/cont/outside/ContResultInsur.screen";
				    f.target = "_self";
				    f.submit();
				} else {
					dlgErrorMsg(resultObj);
				}
			}
		}
		catch(errorObject) {
			showErrorDlg("doResult()", errorObject);
		}
	}

	//첨부파일   
	function doAttachFileDiv(obj) {
		 if(obj==''){
			alert("저장을 한 후 파일을 첨부할 수 있습니다.");
		}
		else if(obj != ''){ 
			viewFileListNew('SUB_CONT_MOD_ID', obj.value, document.getElementById("attach_file_view"), "Y", "cont/outside/<%=ContInfo.get("SUB_CONT_MOD_ID")%>");
		} 
	}
	/**
	 * 첨부파일 예약 함수
	 */
	function fileDown(file_id){
			var url="/common/file/FileDownloadServlet";
	 		url += "?file_id=" + file_id;
	 		
	 		window.open(url, "_fileDown", "toolbar=no, width=400, height=100, top=500, left=400, toolbar=no,directories=no,status=no,scrollbars=yes,resize=no,menubar=no,target=new")
	}	
	
	function doAttachFilePop(obj, No, fObj, fileGB, fileDir) {
		var editFile = "";
		 if(obj==''){
			alert("After you have saved, you can attach a file.");
		}
		else if(obj != ''){ 
			if(fObj.guarStatus.value != "02"){editFile="N";}else{editFile="Y";}
			if('<%= user.get("ACCT_TYPE_CODE")%>' == "ADMIN"){editFile="Y";}
			viewFileListNew(fileGB, obj.value, fObj.p_AttachFileGuar1, editFile, fileDir, "contOutWarrPopup");
		} 
	} 
	//보증정보팝업 호출
	function popContWarr(wG, wSeq, wCauseCd) {
		
		var win_id = "contOutWarrPopup";			
		var param = "";
		var param = "?subContModId=" + jQuery("#SUB_CONT_MOD_ID").val();
		var param = param + "&warrGubun=" + wG;
		var param = param + "&warrSeq=" + wSeq;
		var param = param + "&causeCode=" + wCauseCd;
		var param = param + "&viewDiv=CONT";
		var param = param + "&pop_win_id=" + win_id;
		var param = param + "&sModule=EB";
		
		var url = "/portal/guar/contOutWarrPopup.screen"+param;
		
		fLayerPop(win_id, url, 560,350, '','', 'YES');
	}	
	//보증정보팝업 종료후 액션
	function popContWarrClose(returnValue){
		if(returnValue == null)
			fLayerPopClose('contOutWarrPopup');
		
		if(returnValue[0] == 0){
			fLayerPopClose('contOutWarrPopup');
			location.reload();
		}
	}
	function corpPopup(corpID){
		var url = "/cont/outside/ContTargetPopup.screen";
		url += "?p_corp_id=" + corpID;
		url += "&sModule="+"LM";
		
		window.open(url, "_ContTargetPop","width=1000,height=650,SCROLLBARS=no"); 
	}
	

	/*담당자 호출*/	
	function SearchUserAll(NAME,CODE){
		var win_id = "_searchUserPopup";
		var link = "/lib/dlgSearchUserPop.screen";
		    link += "?pop_win_id="+win_id;
		    link += "&deptNameYn=";
			link += "&NAME=" + NAME;
			link += "&CODE=" + CODE;
			
		fLayerPop(win_id, link, 700,400, '', '', 'NO');
	}
	/*담당자 호출 Return Value 처리*/	
	function SearchUserClose(result){
		if(result.length > 0){
			$("#O_USER_NAME").val(result[1]);
			$("#O_DIVISION").val(result[3]);
			$("#O_POSITION").val(result[5]);
			$("#O_TEL_NUM").val(result[6]);
			$("#O_HP").val(result[7]);
			$("#O_EMAIL").val(result[8]);
			$("#O_ACCT_ID").val(result[9]);
		}
		fLayerPopClose('_searchUserPopup');
	}	
	
</SCRIPT>


<modular:search id="form1">
	<modular:key id="fevent" />
</modular:search>
<form id="form1" name="form1" method="post" modular:type="search">
<INPUT type="hidden" name="fevent" id="fevent" value="<%= params.get("fevent") %>">
<INPUT type="hidden" name="acct_id" value="<%= params.get("acct_id") %>">
<!-- 검색 조건 시작-->
<INPUT type="hidden" name="p_dept_cd" value="<%= params.get("p_dept_cd") %>">
<INPUT type="hidden" name="p_dept_nm" value="<%= params.get("p_dept_nm") %>">
<INPUT type="hidden" name="p_dealer_nm" value="<%= params.get("p_dealer_nm") %>">
<INPUT type="hidden" name="p_cont_status" value="<%= params.get("p_cont_status") %>">
<INPUT type="hidden" name="ContFromDt" value="<%= params.get("ContFromDt") %>">
<INPUT type="hidden" name="ContToDt" value="<%= params.get("ContToDt") %>">
<INPUT type="hidden" name="p_build_nm" value="<%= params.get("p_build_nm") %>">

<INPUT type="hidden" name="ChgCont" value="<%= params.get("ChgCont") %>">
<!-- 검색 조건 끝-->
<INPUT type="hidden" name="CONT_STATUS" value="<%=ContInfo.get("CONT_STATUS")%>">
<INPUT type="hidden" name="SUB_CONT_MOD_ID" value="<%=ContInfo.get("SUB_CONT_MOD_ID")%>">
<INPUT type="hidden" name="SUB_CONT_ID" value="<%=ContInfo.get("SUB_CONT_ID")%>">
<INPUT type="hidden" name="O_CORP_ID" value="<%=ContInfo.get("O_CORP_ID")%>">
<INPUT type="hidden" name="C_CORP_ID" value="<%=ContInfo.get("C_CORP_ID")%>">
<INPUT type="hidden" name="STATUS_CD" value="<%=ContInfo.get("STATUS_CD")%>">
<INPUT type="hidden" name="O_VENDCD" value="<%=ContInfo.get("O_VENDCD")%>">

<!-- 계약서PDF정보  START-->
<INPUT type="hidden" name="TEMPLATE_CD" value="<%=ContInfo.get("TEMPLATE_CD") %>">
<INPUT type="hidden" name="CON_DOC_NO" value="<%=ContInfo.get("CON_DOC_NO") %>">
<INPUT type="hidden" name="MOD_NO" value="<%=ContInfo.get("MOD_NO") %>">
<INPUT type="hidden" name="PDF_FILE_CNT" value="<%=template.size()%>">
<INPUT type="hidden" name="TRUE_RANDOM" value="<%=ContInfo.get("TRUE_RANDOM") %>">
<!-- 계약서PDF정보  END-->

<!--서명 데이터 정보  START-->
<INPUT type='hidden' name="CONT_HASH" value="<%=ContInfo.get("CONT_HASH") %>">
<INPUT type='hidden' name="CONT_SIGNDATA" value="">
<INPUT type='hidden' name="CONT_SIGNDN" value="">
<INPUT type='hidden' name="signeddata" value="">

<INPUT type="hidden" name="O_REG_NO" value="<%=ContInfo.get("O_REG_NO") %>">

	<!-- 제목 및 버튼 -->
<table width="100%">
	<colgroup>
		<col width="500" />
		<col width="*" />
	</colgroup>
	<tr>
	   	<th>
		   <div align="left" id="title">
		    <ul>
		     <li>외주_계약 상세</li>
		    </ul>
		   </div>
	   </th>
	   <td align="right">
			<%
				if ((ContInfo.get("CON_CLS_YN").equals("9")) && (ContInfo.get("MOD_NO").equals(ContInfo.get("MAX_MOD_NO")))){
			%>   
			<!-- <span class="btnSearch center" id="btnChange"><a href="javascript:void(0);">변경계약작성</a></span> -->
			<%} %>
			<span class="btnSearch center" id="btnInsur"><a href="javascript:void(0);">고용보험 신청서</a></span>
			<span class="btnSearch center" id="btnItem"><a href="javascript:void(0);">계약내역</a></span>
			<span class="btnSearch center" id="btnList"><a href="javascript:goListProc();">목록</a></span>
	   </td>
   	</tr>
</table>


<%
	/*
		계약 정보를 한페이지로 만들어서 include 시킴 (2014-08-14) 김명호
	*/	
	String isViewWrite = "V";
	String finalYn = "Y";
	
%>
<%@ include file="/jsp/ko_KR/buyer/cont/outside/ContInfo.jsp" %>


<div class="application-info  magT10">
	<div class="application-sub-title">
		<span class="title">계약정보</span>
	</div>
	<div style="text-align:center;">
	</div>
</div>

<%if (template.size() == 0) { %>
<TABLE class="form-table">
	<colgroup>
		<col width="120px" />
		<col width="24%"/>
		<col width="120px" />
		<col width="24%"/>
		<col width="120px" />
		<col/>
	</colgroup>
  <TR height="25"> 
	<TH>계약일자</TH>
	<TD>		
		<%= InputText.get("CON_DATE", ContInfo.get("CON_DATE"), 10, 50, "hangule,center, desc=계약일자,ReadOnly") %>
		<IMG name="start_img" src="/img/buyer/button/bt_calender.gif" border="0" align="absmiddle" style="cursor:pointer;" onClick="JavaScript:dlgCalendar('CON_DATE');">
	</TD>   
	<TH>계약기간</TH>
	<TD>
		<%= InputText.get("START_WORK_DATE", ContInfo.get("START_WORK_DATE"), 10, 50, "hangule,center, desc=계약일자,ReadOnly") %>
		<IMG name="start_img" src="/img/buyer/button/bt_calender.gif" border="0" align="absmiddle" style="cursor:pointer;" onClick="JavaScript:dlgCalendar('START_WORK_DATE');">
		~
		<%= InputText.get("END_WORK_DATE", ContInfo.get("END_WORK_DATE"), 10, 50, "hangule,center, desc=계약일자,ReadOnly") %>
		<IMG name="start_img" src="/img/buyer/button/bt_calender.gif" border="0" align="absmiddle" style="cursor:pointer;" onClick="JavaScript:dlgCalendar('END_WORK_DATE');">
	</TD> 
	<TH>통화구분</TH>
	<TD><%= InputText.get("CON_CUR_CD", ContInfo.get("CON_CUR_CD"), 30, 20, "required,desc=대표자명,persize,readOnly,class=input_blank,readOnly=white,string,tabIndex=-1") %></TD> 	
  </TR>
  <TR height="25"> 
	<TH>계약계약금액</TH>
	<TD><%= InputText.get("CON_AMT", Formatter.formatCurrency(ContInfo.get("CON_AMT")), 50, 100, "desc=계약금액,persize,readOnly,class=input_blank,readOnly=white,number,tabIndex=-1,right","currinc") %></TD>
	<TH>계약 과세</TH>
	<TD><%= InputText.get("CON_SUPPLY_TAMT", Formatter.formatCurrency(ContInfo.get("CON_SUPPLY_TAMT")), 50, 100, "desc=공급가,persize,readOnly,class=input_blank,readOnly=white,string,tabIndex=-1,right","number") %></TD>    
	<TH>계약  면세/부가세</TH>
	<TD>
		<%= InputText.get("CON_SUPPLY_NAMT", Formatter.formatCurrency(ContInfo.get("CON_SUPPLY_NAMT")), 40, 100, "required,desc=면세,persize,readOnly,class=input_blank,readOnly=white,number,tabIndex=-1,right","number") %>
		/
		<%= InputText.get("CON_SURTAX_AMT", Formatter.formatCurrency(ContInfo.get("CON_SURTAX_AMT")), 40, 100, "required,desc=부가세,persize,readOnly,class=input_blank,readOnly=white,number,tabIndex=-1,right","number") %>
	</TD>         
  </TR>
  <TR height="25"> 
	<TH>선급금금액</TH>
	<TD><%= InputText.get("PREPAY_AMT", Formatter.formatCurrency(ContInfo.get("PREPAY_AMT")), 50, 100, "desc=계약금액,persize,readOnly,class=input_blank,readOnly=white,number,tabIndex=-1,right","currinc") %></TD>
	<TH>선급금 과세</TH>
	<TD><%= InputText.get("PREPAY_SUPPLY_TAMT", Formatter.formatCurrency(ContInfo.get("PREPAY_SUPPLY_TAMT")), 50, 100, "desc=공급가,persize,readOnly,class=input_blank,readOnly=white,string,tabIndex=-1,right","number") %></TD>    
	<TH>선급금 면세/부가세</TH>
	<TD>
		<%= InputText.get("PREPAY_SUPPLY_NAMT", Formatter.formatCurrency(ContInfo.get("PREPAY_SUPPLY_NAMT")), 40, 100, "required,desc=면세,persize,readOnly,class=input_blank,readOnly=white,number,tabIndex=-1,right","number") %>
		/
		<%= InputText.get("PREPAY_SUPPLY_TAMT", Formatter.formatCurrency(ContInfo.get("PREPAY_SUPPLY_TAMT")), 40, 100, "required,desc=부가세,persize,readOnly,class=input_blank,readOnly=white,number,tabIndex=-1,right","number") %>
	</TD>         
  </TR>
  <TR height="25"> 
	<TH>계약이행 보증율</TH>
	<TD><%= InputText.get("CON_EST_GUAR_RATE", ContInfo.get("CON_EST_GUAR_RATE"), 50, 100, "required,desc=계약이행보증율,persize,readOnly,class=input_blank,readOnly=white,string,tabIndex=-1") %></TD>
 	<TH>보증금액</TH>
	<TD><%= InputText.get("CON_EST_GUAR_AMT", Formatter.formatCurrency(ContInfo.get("CON_EST_GUAR_AMT")), 50, 100, "required,desc=계약이행보증금액,persize,readOnly,class=input_blank,readOnly=white,number,tabIndex=-1,right") %></TD>
	<TH>보증기간</TH>
	<TD><%= InputText.get("CON_GUAR_TERM", ContInfo.get("CON_GUAR_TERM"), 50, 100, "required,desc=계약이행보증기간,persize,readOnly,class=input_blank,readOnly=white,string,tabIndex=-1") %></TD> 	
  </TR>  
  <TR height="25"> 
	<TH>하자보수 보증율</TH>
	<TD><%= InputText.get("DEF_EST_GUAR_RATE", ContInfo.get("DEF_EST_GUAR_RATE"), 50, 100, "required,desc=하자보수보증율,persize,readOnly,class=input_blank,readOnly=white,string,tabIndex=-1") %></TD>
 	<TH>보증금액</TH>
	<TD><%= InputText.get("DEF_GUAR_AMT", Formatter.formatCurrency(ContInfo.get("DEF_GUAR_AMT")), 50, 100, "required,desc=하자보수보증금액,persize,readOnly,class=input_blank,readOnly=white,number,tabIndex=-1,right") %></TD>
	<TH>보증기간</TH>
	<TD><%= InputText.get("DEF_EST_TERM", ContInfo.get("DEF_EST_TERM"), 50, 100, "required,desc=하자보수보증기간,persize,readOnly,class=input_blank,readOnly=white,string,tabIndex=-1") %></TD> 	
  </TR>  
  <TR height="25"> 
	<TH>지급조건</TH>
	<TD>
		<INPUT type='hidden' name="PAY_COND_GB" value="<%=ContInfo.get("PAY_COND_GB") %>">
		<%= InputText.get("PAY_COND_GB_NM", ContInfo.get("PAY_COND_GB_NM"), 95, 100, "required,desc=지급조건,persize,readOnly,class=input_blank,readOnly=white,string,tabIndex=-1") %></TD>
 	<TH>지급조건기술</TH>
	<TD><%= InputText.get("PAY_CONTENT", ContInfo.get("PAY_CONTENT"), 95, 100, "required,desc=지급조건기술,persize,readOnly,class=input_blank,readOnly=white,string,tabIndex=-1") %></TD>
	<TH>지급방법</TH>
	<TD>
		현금<%= InputText.get("PAY_WAY_CASH", ContInfo.get("PAY_WAY_CASH"), 30, 100, "required,desc=지체상금율,persize,readOnly,class=input_blank,readOnly=white,string,tabIndex=-1") %>
		/
		어음<%= InputText.get("PAY_WAY_BILL", ContInfo.get("PAY_WAY_BILL"), 30, 100, "required,desc=지체상금율,persize,readOnly,class=input_blank,readOnly=white,string,tabIndex=-1") %>
	</TD> 	
  </TR>  
  <TR height="25"> 
	<TH>지체상금율</TH>
	<TD><%= InputText.get("DELAY_RATE", ContInfo.get("DELAY_RATE"), 95, 100, "required,desc=지체상금율,persize,readOnly,class=input_blank,readOnly=white,string,tabIndex=-1") %></TD> 	
 	<TH>근재보험액</TH>
	<TD><%= InputText.get("LABOR_GUAR_JOIN_AMT_GB", Formatter.formatCurrency(ContInfo.get("LABOR_GUAR_JOIN_AMT_GB")), 20, 100, "required,desc=하자보수보증금액,persize,readOnly,class=input_blank,readOnly=white,number,tabIndex=-1,right") %></TD>
	<TH>노무비</TH>
	<TD><%= InputText.get("LABOR_AMT", Formatter.formatCurrency(ContInfo.get("LABOR_AMT")), 30, 100, "required,desc=노무비,persize,readOnly,class=input_blank,readOnly=white,string,tabIndex=-1") %></TD> 	
  </TR>  
  <TR height="25"> 
	<TH>특이사항</TH>
	<TD colspan="5">
		<textarea name="CON_SPE_TXT" class="input_n" style="width:100%" rows="6" hname="기타사항" ><%=ContInfo.get("CON_SPE_TXT") %></textarea>
	</TD> 	
  </TR>  
  <!-- 계약정보 : 종료 -->
</table>
<%}else{%>
<table width="100%" border="0" cellspacing="0" cellpadding="0" style="border:1px solid black;padding-top:5px">
	<tr>
		<td align="center" bgcolor="#efefef">
			<table width="770px" border="0" cellspacing="0" cellpadding="0">
				<tr>
				  <td align="center">
				  		<%
				  			for(int i = 0 ; i < template.size(); i ++){
				  		%>
				  		<input type="hidden" name="template_seq" value="<%=template.getRow(i).get("SEQ")%>">
				  		<input type="hidden" name="template_name" value="<%=template.getRow(i).get("TEMPLATE_NAME")%>">
				  		<input type="hidden" name="template_style" value="<%=template.getRow(i).get("TEMPLATE_STYLE")%>">
				  		<input type="hidden" name="option_yn" value="<%=template.getRow(i).get("OPTION_YN")%>">
				  		<%	if(i==0){%>
						<span class="tab_on" id="tab_<%=template.getRow(i).get("SEQ")%>" onClick="tabView(<%=template.getRow(i).get("SEQ")%>)">
							<input type="hidden" name="check_yn_<%=template.getRow(i).get("SEQ")%>" value="A">
							<%=template.getRow(i).get("TEMPLATE_NAME")%>
						</span>&nbsp;
						<%	}else{ %>
							<%if((template.getRow(i).get("OPTION_YN").equals("A")) ||(template.getRow(i).get("CHECK_YN").equals("Y"))){ //정상적인 계약서 파일만 보이게 한다. 진행중일경우 체크 박스로 추가 가능%>
							<span class="tab_off" id="tab_<%=template.getRow(i).get("SEQ")%>" onClick="tabView(<%=template.getRow(i).get("SEQ")%>)">
							<input type="hidden" name="check_yn_<%=template.getRow(i).get("SEQ")%>" value="A">
							<%=template.getRow(i).get("TEMPLATE_NAME")%>
							</span>
							<%} %>
						<%	} %>
						<%} %>
				  </td>
				</tr>
			</table>
			<div id="__html" style="width:770px;border:1px solid black;padding:10px 10px 10px 10px;background-color:#FFFFFF;text-align:left;" >
				<%
			  			for(int i = 0 ; i < template.size(); i ++){
			  				String template_html = ClobUtils.getClob((Clob)template.getRow(i).getObject("TEMPLATE_HTML")); 
			  				String divHidden = template.getRow(i).get("SEQ").equals("0")?"":"none";
		  		%>
		  		<div style="display:<%=divHidden%>; padding-top: 10px;overflow:hidden;overflow-y:auto;<%=template.getRow(i).get("TEMPLATE_STYLE") %>" id="__html_<%=template.getRow(i).get("SEQ")%>">
				<%= template_html%>
				</div>
				<%} %>
			</div>
			<br/>
		</td>
	</tr>
</table>			
<%} %>
<div class="application-info magT15">
	<div class="application-sub-title">
		<span class="title">계약서류</span>
	</div>
</div>
<TABLE class="form-table">
	<colgroup>
		<col width="120" />
		<col width="*" />
	</colgroup>
  <TR height="25">
  	<TH>자동생성</TH>
	<TD>
		<table width="100%">
    		<colgroup>
	    		<col width="100%" />
    		</colgroup>		
		<TR height="25">
			<TD>
				<div id="auto_attach_file_view" class="attach_file_view">
					<ul>
	<%
		for(int i=0;i<autofile_list.size();i++){
	%>
					<li><a href="/common/file/FileDownloadServlet?mode=fpDown&filePath=/cont/<%=autofile_list.getRow(i).get("FILE_PATH")%>&fileName=<%=URLEncoder.encode(autofile_list.getRow(i).get("FILE_NAME"), "UTF-8") +"."+ autofile_list.getRow(i).get("FILE_EXT")%>&fileRealName=<%=autofile_list.getRow(i).get("UNIQUE_FILE_NAME")%>"><%=i+1%> : <%=autofile_list.getRow(i).get("FILE_NAME")%> (<%=autofile_list.getRow(i).get("FILE_SIZE").trim() %>)</a></li>
	<%
		}	
	%>
					</ul>
				</div>
			</TD>
		</TR>
		</TABLE>	
	</TD>	
  </TR>
  <TR height="25">
  	<TH>직접첨부</TH>
	<TD>
    	<table width="100%">
    		<colgroup>
	    		<col width="50%" />
				<col width="50%" />
    		</colgroup>
    		<tr>
    		<td>
			    <div id="attach_file_view" class="attach_file_view">
			    <!-- 첨부 파일 화면에 바로보일때 사용 -->
			    <%=FileManager.getFileListForDiv("SUB_CONT_MOD_ID", ContInfo.get("SUB_CONT_MOD_ID")) %>
			    </div>
    		</td>
    		<td>
    			<IMG id="search_spot_button" onClick="doAttachFileDiv(document.form1.SUB_CONT_MOD_ID,1);" src='/img/buyer/button/bt_change.gif' border='0'  align="top" align='absmiddle' alt='[Attach File]' style='cursor:pointer; display: none' >
    			<span class="btnSearch center"><a href="/common/file/FileDownloadServlet?mode=zipDown&fileName=<%=URLEncoder.encode("직접첨부_"+ContInfo.get("CON_DOC_NO") , "UTF-8")%>&fileGB=<%=URLEncoder.encode("SUB_CONT_MOD_ID" , "UTF-8")%>&ID=<%=ContInfo.get("SUB_CONT_MOD_ID")%>">모두저장(ZIP)</a></span> 
    		</td>
    		</tr>
    	</table>		
 	</TD>
  </TR>
</TABLE>
<%if (warrList.size()>0){ %>
<%
	/*
		보증 목록을  include 시킴 (2014-10-16) 김명호
	*/	
%>
<%@ include file="/jsp/ko_KR/buyer/cont/outside/guarList.jsp" %>
<%} %>
</form>

<!-- =========사인 요청 상태이후 (20)에는 입력을 받지 못하게 처리 (김명호 : 2014-07-21)============== -->
<script>
//window.addEventListener("onload",convertHtml)
<%
	if((ContInfo.get("STATUS_CD").equals("20")) || (ContInfo.get("STATUS_CD").equals("30")) || (ContInfo.get("STATUS_CD").equals("50"))){
%>
	window.onload = function() {  
		convertHtml();
	};	
<%
	}
%>
function convertHtml(){
	if(!document.getElementById("__html"))return;
	var elements = document.getElementById("__html").getElementsByTagName("input");
	for(var i = 0; i < elements.length; i++){
		var element = elements[i];
		setDisabled(element);
	}
	var elements = document.getElementById("__html").getElementsByTagName("textarea");
	for(var i = 0; i < elements.length; i++){
		var element = elements[i];
		element.className = "input_readonly";
		element.readOnly = true;
	}
	var elements = document.getElementById("__html").getElementsByTagName("img");
	for(var i = 0; i < elements.length; i++){
		var element = elements[i];
		element.style.display="none";
	}
	/*협력사에서 안보이는 부분숨기는 처리*/
	var elements = getElementsByClass("cl_no_view");
	for(var i = 0; i < elements.length; i++){
		var element = elements[i];
		element.style.display="none";
	}
}
</script>
