<%--
  - Author(s)  : Kim Myung HO
  - Date       : 2014.07.07
  - 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.*" %>
<%@ include file="/jsp/work/taglib.jsp" %>
<%@ 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");

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

    /*계약 구매 내역 목록*/
    RowSet itemList = storage.getRowSet("itemList");
    
    /*인지세 구분*/
    RowSet stampList = storage.getRowSet("stampRowSet");
    
    //변경계약일경우 이전 차수에서 데이터를 가져온다.
    ValueObject OldContInfo = null;
    if(params.get("ChgCont").equals("Y")){
    	OldContInfo = storage.getValueObject("OldContInfo");
    }  
    
	//변경계약내역서 추가 2019.08.06
	RowSet chgItemList = storage.getRowSet("chgItemList");
%>
<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;
	var payCallNum = 1;		//대금계획에서 화면 이동 정의

	function _onReady(){
		/* STAMP_DUTY, PROMISE_DOC 인클루드 페이지 기능 */
		
		gridInit2(sheet2);
		gridInit3(sheet3);
		gridInit4(sheet4);
		doSearchStamp();
		doSearchPromise();
		doSearchPricesys();
		
		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);
			jQuery("#p_pricesys_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);
			jQuery("#p_pricesys_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();	
			}
		}
		
		jQuery("#btnAdd").click(function() {
			var rowIdx = sheet2.DataInsert(-1);
			if(jQuery("#p_issue_gb").val()=="10"){
				sheet2.SetCellValue(rowIdx, "STAMP_DUTY_ISSUE_GB", "10");
			}else{
				sheet2.SetCellValue(rowIdx, "STAMP_DUTY_ISSUE_GB", "20");
			}
		});
		
		jQuery("#btnPromiseAdd").click(function() {
			var rowIdx = sheet3.DataInsert(-1);
			if(jQuery("#p_promise_gb").val()=="10"){
				sheet3.SetCellValue(rowIdx, "PROMISE_DOC_TYPE_GB", "10");
			}else{
				sheet3.SetCellValue(rowIdx, "PROMISE_DOC_TYPE_GB", "20");
			}
		});

		jQuery("#btnPricesysAdd").click(function() {
			var rowIdx = sheet4.DataInsert(-1);
			if(jQuery("#p_pricesys_gb").val()=="01"){
				sheet4.SetCellValue(rowIdx, "PRICE_SYS_YN", "01");
			}else{
				sheet4.SetCellValue(rowIdx, "PRICE_SYS_YN", "02");
				sheet4.SetCellValue(rowIdx, "OBJECT_ITEM", "별도 협의");
				sheet4.SetCellValue(rowIdx, "SYS_REASON", "별도 협의");
			}
		});
		
		/**
		 *	Application Initialize
		 */
		jQuery("#btn_list").click(function() {
			jQuery("#fevent").val("");
			jQuery("#form1").attr("action", "/bid/purchase/OrderReqeustList.screen");
			jQuery("#form1").attr("target", "_self");
			jQuery("#form1").attr("method", "post");
			jQuery("#form1").submit();
		});
		jQuery("#ELEC_CON_YN1").click(function() {
			jQuery("#ELEC_CON_YN1").attr("checked",true);
			jQuery("#ELEC_CON_YN2").attr("checked",false);
		});
		jQuery("#ELEC_CON_YN2").click(function() {
			jQuery("#ELEC_CON_YN1").attr("checked",false);
			jQuery("#ELEC_CON_YN2").attr("checked",true);
		});
		
		jQuery("#btnSave").click(function() {
			
			if(jQuery('#p_issue_gb').val() == '00' && sheet2.GetTotalRows() != 0 ){
				for(i=1; i <= sheet2.RowCount(); i++){
					if(sheet2.GetCellValue(i, "STATUS")!="D"){
						alert("인지세 발급 구분을 미발행으로 등록하려면\n인지세가 등록되어있거나 등록해서는 안됩니다.\n인지세를 삭제하여 주십시오.");
						return;
					}
				}
			}
			
			if(jQuery('#p_promise_gb').val() == '00' && sheet3.GetTotalRows() != 0 ){
				for(i=1; i <= sheet3.RowCount(); i++){
					if(sheet3.GetCellValue(i, "STATUS")!="D"){
						alert("서약서를 미발행으로 등록하려면\n서약서가 등록되어있거나 등록해서는 안됩니다.\n서약서를 삭제하여 주십시오.");
						return;
					}
				}
			}
			
			if(ck()){
				alert("[전자 계약 여부]는 필수 입니다.");
				return;
			}
			if(jQuery("#mod_gb").val() == ""){
				alert("변경내역을 선택해 주세요");
				return;
			}	
			//변경계약일경우 체크 프로세스 태운다. 2014-11-14 김명호 추가
			if(jQuery("#mod_gb").val() != "00"){
				if(!changeValCheck()){
					return;
				}						
			}		
				
			/* for(i=1; i <= sheet2.RowCount(); i++){
				if(sheet2.GetCellValue(i, "STATUS")!="D"){
					if(sheet2.GetCellValue(i, "STAMP_DUTY_NO")==""){
						alert(i+"행의 고유식별번호가 없습니다.");
						return false;
					}
					if(sheet2.GetCellValue(i, "STAMP_DUTY_TAX")=="" || sheet2.GetCellValue(i, "STAMP_DUTY_TAX")<=0){
						alert(i+"행의 인지세가 없거나 인지세가 0보다 작거나 같습니다.\n인지세는 0보다 커야합니다.");
						return false;
					}
					if(sheet2.GetCellValue(i, "STAMP_DUTY_DATE")==""){
						alert(i+"행의 발행일자가 없습니다.");
						return false;
					}
				}
			} */
		
			if(!checkTelno(jQuery("#O_TEL_NUM").val())) {
				alert("전화번호가 올바르지 않은 형식입니다");
				jQuery("#O_TEL_NUM").focus();
				return;
			}    			
			if(!checkTelno(jQuery("#O_HP").val())) {
				alert("휴대폰번호가 올바르지 않은 형식입니다");
				jQuery("#O_HP").focus();
				return;
			}  			
			if(!checkTelno(jQuery("#C_TEL_NUM").val())) {
				alert("전화번호가 올바르지 않은 형식입니다");
				jQuery("#C_TEL_NUM").focus();
				return;
			}    			
			if(!checkTelno(jQuery("#C_HP").val())) {
				alert("휴대폰번호가 올바르지 않은 형식입니다");
				jQuery("#C_HP").focus();
				return;
			} 			
			if(!checkEmail(jQuery("#O_EMAIL").val())){
				alert("이메일 형식이 올바르지 않습니다.");
				jQuery("#O_EMAIL").focus();
				return;
			}
			if(!checkEmail(jQuery("#C_EMAIL").val())){
				alert("이메일 형식이 올바르지 않습니다.");
				jQuery("#C_EMAIL").focus();
				return;
			}
			
			<%if(params.get("TEMPLATE_CD").equals("3")){%>
				if(form1.con_guar_amt_rate.value== "" && form1.amtRate1.checked==true){  //2021.07.29 
					alert("계약이행 보증율을 입력해 주세요.");
					form1.con_guar_amt_rate.focus;
					return;
				}
				if(form1.def_guar_amt_rate.value== "" && form1.amtRate2.checked==true ){ 
					alert("하자이행 보증율을 입력해 주세요.");
					form1.def_guar_amt_rate.focus;
					return;
				}
				if(form1.con_guar_terms1.value== "" && form1.amtRate3.checked==true ){ 
					alert("지급이행 보증기한을 입력해 주세요.");
					form1.def_guar_amt_rate.focus;
					return;
				}
			<%}%>
			
			<%if(!ContInfo.get("DIV_PO_YN").equals("Y")){%>
				if(form1.ord_supply_amt.value== ""){
					alert("공급가액을 입력해 주세요.");
					form1.ord_supply_amt.focus;
					return;
				}
				<%if((!params.get("TEMPLATE_CD").equals("6"))&& (!params.get("TEMPLATE_CD").equals("10"))){%>
					<%if(params.get("TEMPLATE_CD").equals("3")){%>
						if(form1.con_guar_amt_rate.value== "" && form1.amtRate1.checked==true){
							alert("계약이행 보증율을 입력해 주세요.");
							form1.con_guar_amt_rate.focus;
							return;
						}
						if(form1.def_guar_amt_rate.value== "" && form1.amtRate2.checked==true ){ 
							alert("하자이행 보증율을 입력해 주세요.");
							form1.def_guar_amt_rate.focus;
							return;
						}
						if(form1.con_guar_terms1.value== "" && form1.amtRate3.checked==true ){ 
							alert("지급이행 보증기한을 입력해 주세요.");
							form1.def_guar_amt_rate.focus;
							return;
						}
					<%}else{%>
						if(form1.con_guar_amt_rate.value== "" ){  
							alert("계약이행 보증율을 입력해 주세요.");
							form1.con_guar_amt_rate.focus;
							return;
						}
						if(form1.def_guar_amt_rate.value== ""  ){ 
							alert("하자이행 보증율을 입력해 주세요.");
							form1.def_guar_amt_rate.focus;
							return;
						}
					<%}%>
					//공급가 기준(KRW : 10,000,000이상, USD : 10,000이상일 경우 계약이행,하자보수 보증증권 시행)		2021.02.02 최훈석	
					if(form1.con_guar_amt_rate.value == "0" ||	form1.def_guar_amt_rate.value == "0"){
						var guar_nm = "";
						if(form1.con_guar_amt_rate.value == "0" && form1.def_guar_amt_rate.value == "0"){
							guar_nm = "(계약, 하자)";
						}else if(form1.con_guar_amt_rate.value == "0"){
							guar_nm = "(계약)";
						}else if(form1.def_guar_amt_rate.value == "0"){
							guar_nm = "(하자)";
						}
						
						if(jQuery("#CURRENCY_GB").val() == "KRW"){		
							if(form1.ord_supply_amt.value.replaceAll(",","") >= 10000000){
								if(!confirm("계약금 1,000만원 이상이나 보증율"+guar_nm+"이\n등록되지 않았습니다.\n\n그래도 진행하시겠습니까? ")){
									return;
								}
							}
						}else if(jQuery("#CURRENCY_GB").val() == "USD"){
							if(form1.ord_supply_amt.value.replaceAll(",","") >= 10000){
								if(!confirm("계약금 10,000달러 이상이나 보증율"+guar_nm+"이\n등록되지 않았습니다.\n\n그래도 진행하시겠습니까?")){						
									return;
								}
							}
						}	
					}
<%				}
			}
%>
			<%if(!(params.get("TEMPLATE_CD").equals("4"))&&!(params.get("TEMPLATE_CD").equals("15"))){%>
			 if(parseFloat_isNaN(form1.prepay_amt_rate.value)+parseFloat_isNaN(form1.mid_amt_rate.value)+parseFloat_isNaN(form1.rmdr_amt_rate.value) != 100){ //2018.08.13
				if(!confirm("대금 지불 방법의 총 합은 100%아닙니다.\n\n그래도 진행하시겠습니까?")){
					form1.prepay_amt_rate.focus;
					return;
				}
			} 
			<%}%>
			<%if((params.get("TEMPLATE_CD").equals("9")) || (params.get("TEMPLATE_CD").equals("10"))){%>
			//자유서식일경우 첨부 파일은 필수
			if(jQuery("#p_AttachFile1").val() == ""){
				alert('자유서식 계약일 경우 첨부파일은 필수 사항입니다.');							
				return;
			}	
			<%}%>
			//변경계약일경우 체크  - 처음은 변경 내역만 비교 했지만 나중(2014-11-24 상품 내역도 수정이 추가 되어 합계 비료를 하게 되었음.)
			//if(!jQuery("#pDemID").val()==""){
				//var chg_ord_spply_amt = form1.ord_supply_amt.value.replace(/,/gi,"");

				var chg_ord_spply_amt = Number(form1.ord_supply_amt.value.replace(/,/gi,"")*1);
				var item_amt_sum = Number(form1.ITEM_AMT_SUM.value.replace(/,/gi,"")*1);
				item_amt_sum = item_amt_sum.toFixed(Number(form1.sosuNum.value));  //2018.10.31 내역과 계약갑지 소수점 처리 
				
				if(item_amt_sum != chg_ord_spply_amt){
					alert("상품 내역의 총 합과 계약 금액과 다릅니다.\n\n내역 팝업을 띄워서 총 합을 확인해 주시기 바랍니다.");
					form1.ord_supply_amt.focus;
					return;
				}
		//	}
			
			if(!chkContHtml()){
				return;
			}
			//대금 계획 체크 2016.4.26 원계약일때만 계획체크 
			<%if(ContInfo.get("PAY_DIV").equals("2") && ContInfo.getInt("MOD_NO") <= 0 ){%>	//PAY_DIV 가 2인 설치일때만 대금계획을 저장한다.
			if(!paySaveChk()){
				return;
			}			
			<%}%>
			
			//분개유형 DEFAULT(-선택-)일 경우 팝업 출력(2020.12.28)
			if(jQuery("#acct_gb").val() == "0"){		
				alert("분개유형을 선택해 주시기 바랍니다.");				
				return;
			}
			
			<%if((params.get("TEMPLATE_CD").equals("4")) || (params.get("TEMPLATE_CD").equals("9")) || (params.get("TEMPLATE_CD").equals("13"))){%>
			//영세 세금계산서일 경우 부가세에 금액이 있다면 팝업 출력(변경예정)
			if(jQuery("#gua_gb").val() == "23"){		
				if(form1.ord_surtax_amt.value != "0"){
					if(!confirm("영세(세금계산서)이나 부가세가 등록되어 있습니다.\n\n그래도 진행하시겠습니까?")){
						form1.ord_surtax_amt.focus;
						return;
					}
				}
			}
			<%}%>
			
			if (confirm("저장 하시겠습니까?")){
				var f = document.form1;
				submitXmlRequest("/cont/purchase/ContWrite_form.screen", "PARTNER_EMP_CHK", f, "VALUEOBJECT");
				document.form1.isSubmit = false;
				
				/* var f = document.form1;
				jQuery("#fevent").val("FORM_SAVE");
				submitXmlRequest("/cont/purchase/ContWrite_form.screen", "FORM_SAVE", f); */
				
			}
		});
		
		//변경계약 삭제
		jQuery("#btnDel").click(function() {			
			if (confirm("변경계약을  삭제 하시겠습니까?")){
				var f = document.form1;
				jQuery("#fevent").val("FORM_DEL_CHG");  //2017.04.12 변경계약대상에서 삭제 
				submitXmlRequest("/cont/purchase/ContWrite_form.screen", "FORM_DEL_CHG", f);
			}
		});	
		//변경계약대상 변경시행결의 진행 2016.03.09
		jQuery("#btnDeciSave").click(function() {	
            stampMsg = '계약정보 저장 후 결재화면이 활성화 됩니다.\n\n결재요청 요청하시겠습니까?';
			
			if (confirm(stampMsg)){
				var f = document.form1;
				jQuery("#fevent").val("FORM_DEC_SAVE");  //예산금액만 저장. 상태값 확인 
				submitXmlRequest("/cont/purchase/ContWrite_form.screen", "FORM_DEC_SAVE", f);
			}			
			
		});	
				
		//계약서 삭제
		jQuery("#btnDelete").click(function() {			
			if (confirm("계약서를 삭제 하시겠습니까?")){
				var f = document.form1;
				jQuery("#fevent").val("FORM_DELETE");
				submitXmlRequest("/cont/purchase/ContWrite_form.screen", "FORM_DELETE", f, "SUCCESS");
			}
		});	
		
		//변경계약일경우 내역 팝업
		jQuery("#btnChgItem").click(function() {			
			var win_id = "chgItemPop";	
			var editYN = "Y";
			var link = "/cont/purchase/chgItemPopup.screen";
			link += "?pop_win_id="+win_id+"&PUR_CONT_MOD_ID="+$("#PUR_CONT_MOD_ID").val()+"&PUR_CONT_ID="+$("#PUR_CONT_ID").val()+"&pDemID="+$("#pDemID").val()+"&digit="+$("#sosuNum").val()+"&editYN="+ editYN;
			fLayerPop(win_id, link, 950,500, '','', 'NO');
		});		
		//계약 내역 팝업
		jQuery("#btnItem").click(function() {			
			var win_id = "ItemPop";			
			var editYN = "Y";
			var link = "/cont/purchase/ItemPopup.screen";
			link += "?pop_win_id="+win_id+"&PUR_CONT_MOD_ID="+$("#PUR_CONT_MOD_ID").val()+"&PUR_CONT_ID="+$("#PUR_CONT_ID").val()+"&pDemID="+$("#pDemID").val()+"&TEMPLATE_CD="+$("#TEMPLATE_CD").val()+"&DIV_PO_YN="+$("#DIV_PO_YN").val()+"&digit="+$("#sosuNum").val()+"&curr_std_nm="+encodeURI(encodeURIComponent($("#CURR_STD_NM").val()),"UTF-8")+"&editYN="+ editYN;
			fLayerPop(win_id, link, 950,500, '','', 'NO');
		});	
		
		chgModGb(jQuery("#mod_gb").val());
		
		//2019.11.22 변경계약일경우 계약상품내역 확인 문구 추가 요청 - 송영주 과장
		<%if(params.get("ChgCont").equals("Y")){%>
			alert("계약상품내역을 먼저 확인후 작성해주세요.");
		<%}%>
	} 

	function ck(){
		if($("#ELEC_CON_YN1").attr("checked") == "checked"){
			return false;	
		}
		if($("#ELEC_CON_YN2").attr("checked") == "checked"){
			return false;
		}
		return true;
	}

	
	
	//자동로그인 기능
	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/purchase/ContTargetList.screen";
	    f.target = "_self";
	    f.submit();
	}

	function doResult(resultObj) {
		try {
			if( resultObj.getRequestEvent() == "PARTNER_EMP_CHK") {
				if( resultObj.getSuccess() ) {
					var vo = resultObj.getValueObject();
					var cnt = vo.get("EMP_CHK_CNT");
					if(cnt > 0){
						var f = document.form1;
						jQuery("#fevent").val("FORM_SAVE");
						submitXmlRequest("/cont/purchase/ContWrite_form.screen", "FORM_SAVE", f);
					}else{
						if(confirm("등록된 업체담당자 정보와 일치하지 않습니다. 계속진행하시겠습니까?")){
							var f = document.form1;
							jQuery("#fevent").val("FORM_SAVE");
							submitXmlRequest("/cont/purchase/ContWrite_form.screen", "FORM_SAVE", f);
						}else{
							return;
						}
					}
				}else {
					dlgErrorMsg(resultObj);
				}
				document.form1.isSubmit = false;
			}
			if( resultObj.getRequestEvent() == "FORM_SAVE") {
				if( resultObj.getSuccess() ) {
 				jQuery("#save_gb").val("Y");
 				doSaveStamp();
 				doSavePromise();
 				doSavePricesys();
				//2016.4.27 변경일때 제외 
				<%if(ContInfo.get("PAY_DIV").equals("2") && ContInfo.getInt("MOD_NO") <= 0){%>	//PAY_DIV 가 2인 설치일때만 대금계획을 저장한다.
					payPlanSave();	//대금 계획 저장
				<%}else{%>
					alert("계약서저장에 성공하였습니다.\n\n저장된 계약서는 구매_계약현황페이지에서 확인하실수 있습니다.");
					location.href="/cont/purchase/ContIngList.screen";
 				//	goListProc();
 				<%}%>
				}
				else {
					dlgErrorMsg(resultObj);
				}
			}
			//2016.03.09
			if( resultObj.getRequestEvent() == "FORM_DEC_SAVE") {
				if( resultObj.getSuccess() ) {
 					jQuery("#save_gb").val("Y");
 					document.form1.isSubmit = false;
 					var f = document.form1;
 					var sign_cont_mod_id = $("#PUR_CONT_MOD_ID").val();
 					dlgSignForm('ebid_pcpoD', '/cont/purchase/contSign.screen?sign_cont_mod_id='+sign_cont_mod_id+'^acct_id='+"<%=user.get("ACCT_ID")%>");
 				}
				else {
					dlgErrorMsg(resultObj);
				}
			}
			
			//계약서 삭제
			if( resultObj.getRequestEvent() == "FORM_DEL") {
				if( resultObj.getSuccess() ) {
					alert("정상적으로 삭제 처리 되었습니다.")
					goListProc();
				} else {
					dlgErrorMsg(resultObj);
				}
			}
			//2017.04.12 변경계약 대상->접수로 이동 
			if( resultObj.getRequestEvent() == "FORM_DEL_CHG") {
				if( resultObj.getSuccess() ) {
					alert("정상적으로 삭제 처리 되었습니다.")
					goListProc();
				} else {
					dlgErrorMsg(resultObj);
				}
			}
			//계약서 삭제
			if( resultObj.getRequestEvent() == "FORM_DELETE") {
				if( resultObj.getSuccess() ) {
					alert("정상적으로 삭제 처리 되었습니다.");
					goListProc();
				} else {
					dlgErrorMsg(resultObj);
				}
			}
			document.form1.isSubmit = false;

		}
		catch(errorObject) {
			showErrorDlg("doResult()", errorObject);
		}
	}
	
	//결재2016.03.09
	function dlgSignForm( sign_class_cd, uri ) {
		var f = document.form1;
		var sheet1 = document.all.sheet1;
		var url = "/contPurchaseSign/contSign_form.screen";
		url += "?sign_class_cd=" + sign_class_cd;
		url += "&uri="           + uri;
		url += "&sign_cont_mod_id="   + $("#PUR_CONT_MOD_ID").val();
		url += "&acct_type=1";
		window.open(url, "_blank","width=200,height=100,SCROLLBARS=no");
	}
	/*담당자 호출*/	
	var pCallPop = "";
	function SearchUser(pGuBun,NAME,CODE){
		pCallPop = pGuBun;
		var win_id = "_searchUserPopup";
		var link = "/lib/dlgSearchUserPop.screen";
		    link += "?pop_win_id="+win_id;
		    if(pCallPop != "Sheet"){
		    link += "&deptNameYn=purchase";
		    }
		    link += "&NAME=" + NAME;
		    link += "&CODE=" + CODE;
		fLayerPop(win_id, link, 700,400, '', '', 'NO');
	}
	/*담당자 호출 Return Value 처리*/	
	function SearchUserClose(result){
		if(result.length > 0){
			if(pCallPop == "Sheet"){
				sheet1.SetCellValue(clickRow, "VP_CHK_EMPNO", result[9]);   //밴더프린트 담당자 아이디
				sheet1.SetCellValue(clickRow, "VP_CHK_EMPNM", result[1]);   //밴더프린트 담당자명				
			}else{
				$("#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]);
				replaceInput(result[3],"req_dept_nm"	,__html);				
			}
		}
		fLayerPopClose('_searchUserPopup');
	}	
	/*계약서 pdf script start*/
	function chkContHtml(){
		var f = document.form1;
		var c = $("#PDF_FILE_CNT").val();
		if(validate(f)){
			splitHtml(f, 'cont_html', false, c);
			splitHtml(f, 'cont_html_rm', true, c);
			return true;
		}
		return false;
	}
	/*계약서 pdf script end*/	

	//첨부파일   
	function doAttachFile(obj) {
		 if(obj==''){
			alert("저장을 한 후 파일을 첨부할 수 있습니다.");
		}
		else if(obj != ''){ 
			viewFileListNew('PUR_CONT_MOD_ID', obj.value, document.getElementById("p_AttachFile1"), "Y", "cont/purchase/<%=ContInfo.get("PUR_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")
	}	
</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="save_gb" id="save_gb" value="">
<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="CONT_STATUS" value="<%=ContInfo.get("CONT_STATUS")%>">
<INPUT type="hidden" name="STATUS_CD" value="<%=ContInfo.get("STATUS_CD")%>">
<INPUT type="hidden" name="PUR_CONT_MOD_ID" value="<%=ContInfo.get("PUR_CONT_MOD_ID")%>">
<INPUT type="hidden" name="PUR_CONT_ID" value="<%=ContInfo.get("PUR_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="ChgCont" value="<%= params.get("ChgCont") %>">
<INPUT type='hidden' name="CURR_STD_NM" value="<%= ContInfo.get("CURR_STD_NM") %>">

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

<!-- 아이템 총 합계금액  및 발주 의뢰 번호 -->
<INPUT type="hidden" name="ITEM_AMT_SUM" value="<%=ContInfo.get("ITEM_AMT_SUM") %>">
<INPUT type="hidden" name="pDemID" value="<%=ContInfo.get("DEM_ID") %>">
<INPUT type="hidden" name="DIV_PO_YN" value="<%=ContInfo.get("DIV_PO_YN") %>">

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

<INPUT type="hidden" name="T_CON_GUAR_AMT_RATE" value="<%=ContInfo.get("CON_GUAR_AMT_RATE") %>">
<INPUT type="hidden" name="T_CON_GUAR_TERMS" value="납품기한에 30일을 더한 날까지">
<INPUT type="hidden" name="T_CON_GUAR_AMT" value="<%=ContInfo.get("CON_GUAR_AMT") %>">

<INPUT type="hidden" name="T_DEF_GUAR_AMT_RATE" value="<%=ContInfo.get("DEF_GUAR_AMT_RATE") %>">
<INPUT type="hidden" name="T_DEF_GUAR_AMT" value="<%=ContInfo.get("DEF_GUAR_AMT") %>">

<INPUT type="hidden" name="O_ACCT_ID" id="O_ACCT_ID" value="<%=ContInfo.get("CON_CHARGE_ID")%>">
<INPUT type="hidden" name="input_vat" value="<%=ContInfo.get("INPUT_VAT") %>">

<!-- 제목 및 버튼 -->
<table width="100%">
	<colgroup>
		<col width="500" />
		<col width="*" />
	</colgroup>
	<tr>
	   	<th>
		   <div align="left" id="title">
		    <ul>
		     <li>구매_<%if(params.get("ChgCont").equals("Y")){%>변경<%} %>계약대상 상세</li>
		    </ul>
		   </div>
	   </th>
	   <td align="right">
			<span class="btnSearch center" id="btnSave"><a href="javascript:void(0);">저장</a></span>
			<%if(ContInfo.get("MOD_NO").equals("0")  && (ContInfo.get("STATUS_CD").equals("") || ContInfo.get("STATUS_CD").equals("00"))){%>
	   		<span class="btnSearch center" id="btnDelete"><a href="javascript:void(0);">삭제</a></span>
	   		<%}%>
			<span class="btnSearch center" id="btnList"><a href="javascript:goListProc();">목록</a></span>
<%
if((params.get("TEMPLATE_CD").equals("6")) || (params.get("TEMPLATE_CD").equals("10"))){	//변경계약일경우 변경내역 팝업 
			//변경 계약일경우 계약서 삭제 가능
	if(!ContInfo.get("DEM_ID").isEmpty()){
%>			
			<span class="btnSearch center" id="btnChgItem"><a href="javascript:void(0);">변경계약내역</a></span>
<%
	}else{
%>
			<span class="btnSearch center" id="btnItem"><a href="javascript:void(0);">계약상품내역</a></span>
<%
	}
%>
			<span class="btnSearch center" id="btnDel"><a href="javascript:void(0);">변경계약서삭제</a></span>
			<!-- <span class="btnSearch center" id="btnDeciSave"><a href="javascript:void(0);">결재</a></span> 2016.03.09 -->
<%	
}else{
%>			
			<span class="btnSearch center" id="btnItem"><a href="javascript:void(0);">계약상품내역</a></span>
<%
}
%>			
	   </td>
   	</tr>
</table>

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



<div class="application-info  magT10">
	<div class="application-sub-title">
		<span class="title">계약정보</span>
	</div>
	<div style="text-align:center;">
    <%if (params.get("ChgCont").equals("Y")) {		//변경 계약서 일경우 추가 내역%>
    	변경구분
		<select name="mod_gb" onchange="chgModGb(this.value)">
			<option value="">-선택-</option>
			<option value="01" <%=ContInfo.get("MOD_GB").equals("01") ? "selected=selected":""%>>증액</option>
			<option value="02" <%=ContInfo.get("MOD_GB").equals("02") ? "selected=selected":""%>>감액</option>
			<option value="10" <%=ContInfo.get("MOD_GB").equals("10") ? "selected=selected":""%>>연장</option>
			<option value="11" <%=ContInfo.get("MOD_GB").equals("11") ? "selected=selected":""%>>연장증액</option>
			<option value="12" <%=ContInfo.get("MOD_GB").equals("12") ? "selected=selected":""%>>연장감액</option>
			<option value="20" <%=ContInfo.get("MOD_GB").equals("20") ? "selected=selected":""%>>단축</option>
			<option value="21" <%=ContInfo.get("MOD_GB").equals("21") ? "selected=selected":""%>>단축증액</option>
			<option value="22" <%=ContInfo.get("MOD_GB").equals("22") ? "selected=selected":""%>>단축감액</option>
			<option value="98" <%=ContInfo.get("MOD_GB").equals("98") ? "selected=selected":""%>>계약이관</option>
			<option value="99" <%=ContInfo.get("MOD_GB").equals("99") ? "selected=selected":""%>>기타</option>
		</select>
    <% } else { //당초 일경우 기본 값%>
    	<input type="hidden" name="mod_gb" id ="mod_gb" value="<%=ContInfo.get("MOD_GB")%>" />
    <% }%>
    <font color="ffffff">......</font>
    	※<span style="background-color:yellow;text-align:center">노랑색</span>은 필수입력사항, <span style="text-align:center;background-color:#CCFF99;">연두색</span>은 계약서에 인쇄되지 않는 항목입니다.
	</div>
</div>

<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>
					<%	}else{ %>
					<span class="tab_off" id="tab_<%=template.getRow(i).get("SEQ")%>" onClick="tabView(<%=template.getRow(i).get("SEQ")%>)">
						<%if(template.getRow(i).get("OPTION_YN").equals("A")){%>
						<input type="hidden" name="check_yn_<%=template.getRow(i).get("SEQ")%>" value="A">
						<%}else if(template.getRow(i).get("OPTION_YN").equals("Y")){ %>
						<input type="checkbox" name="check_yn_<%=template.getRow(i).get("SEQ")%>" value="Y" <%if(template.getRow(i).get("DEFAULT_YN").equals("Y")){%>checked="checked"<%}%>>
						<%} %>
						<%=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/>
				<col WIDTH="30PX"/>
    		</colgroup>
    		<tr>
    		<td>
    			<TEXTAREA name="p_AttachFile1" id="p_AttachFile1" style="width:100%;height:50px;border:0;" rows="1" class="input" readOnly><%=FileManager.getFileListForTextarea("PUR_CONT_MOD_ID", ContInfo.get("PUR_CONT_MOD_ID")) %></TEXTAREA>
    		</td>
    		<td VALIGN="TOP">
    			<IMG id='search_spot_button' onClick="doAttachFile(document.form1.PUR_CONT_MOD_ID,1);" src='/img/buyer/button/bt_change.gif' border='0'  align="top" align='absmiddle' alt='[Attach File]' style='cursor:pointer;'>
    		</td>
    		</tr>
    	</table>		

 	</TD>
  </TR>
 </TABLE>
</form>
<!-- -인도 조건 셋팅 -->
<!-- 인도 조건 코드 겁색 팝업 -->
<script type="text/javascript">
<!--
/**
 * 상세 코드 검색
 */
function popSearchCodeDetail(bcd)
{
	var win_id = "_searchCodePopup";
	var link = "/sycs/code/dlgCodePopup.screen";
	    link += "?pop_win_id="+win_id;
	    link += "&p_basecd="+bcd;
	fLayerPop(win_id, link, 600,400, '', '', 'NO');

}
function SearchCodeDetailClose(result){
	if(result != null){
		if(result[2]=="PUR_CON_GB"){
			replaceInput(result[0],"con_gb"		,__html);
			replaceInput(result[1],"spn_con_gb"	,__html);			
		}else{
			replaceInput(result[0],"lead_cond_gb"		,__html);
			replaceInput(result[1],"spn_lead_cond_gb"	,__html);
		}
	}
	fLayerPopClose('_searchCodePopup');
}	
//2017.07.14 구매 영세율일때 부가세별도 문구 삭제 
function VatTextChange()
{
	var f = document.form1;
	  if ("<%= params.get("TEMPLATE_CD")%>" == "3"){ //template_cd 기자재공급계약서 
		  if (f.input_vat.value == "INPUT_VAT") {  //부가세   
				replaceInput("-부가세별도","vat_gb"	,__html);
			}else{
		  	    replaceInput(" ","vat_gb"	,__html);
			}
	  }		
}
//-->
</script>
<script>
//계약일자
<%
	String ord_con_date_year = ""; 
	String ord_con_date_month = "";
	String ord_con_date_day = "";
	if(!ContInfo.get("ORD_CON_DATE").equals("")){
		ord_con_date_year = ContInfo.get("ORD_CON_DATE").replaceAll("-","").substring(0,4);
		ord_con_date_month = ContInfo.get("ORD_CON_DATE").replaceAll("-","").substring(4,6);
		ord_con_date_day = ContInfo.get("ORD_CON_DATE").replaceAll("-","").substring(6,8);
	}
%>

replaceInput("<%=ord_con_date_year%>","ord_con_date_year",__html);
replaceInput("<%=ord_con_date_month%>","ord_con_date_month",__html);
replaceInput("<%=ord_con_date_day%>","ord_con_date_day",__html);

replaceInput("<%=ord_con_date_year%>","o_ord_cont_date_year",__html);
replaceInput("<%=ord_con_date_month%>","o_ord_cont_date_month",__html);
replaceInput("<%=ord_con_date_day%>","o_ord_cont_date_day",__html);

//공사기간
<%
	String ord_start_date_year = ""; 
	String ord_start_date_month = "";
	String ord_start_date_day = "";
	if(!ContInfo.get("ORD_START_DATE").equals("")){
		ord_start_date_year = ContInfo.get("ORD_START_DATE").replaceAll("-","").substring(0,4);
		ord_start_date_month = ContInfo.get("ORD_START_DATE").replaceAll("-","").substring(4,6);
		ord_start_date_day = ContInfo.get("ORD_START_DATE").replaceAll("-","").substring(6,8);
	}
	
	String ord_end_date_year = ""; 
	String ord_end_date_month = "";
	String ord_end_date_day = "";
	if(!ContInfo.get("ORD_END_DATE").equals("")){
		ord_end_date_year = ContInfo.get("ORD_END_DATE").replaceAll("-","").substring(0,4);
		ord_end_date_month = ContInfo.get("ORD_END_DATE").replaceAll("-","").substring(4,6);
		ord_end_date_day = ContInfo.get("ORD_END_DATE").replaceAll("-","").substring(6,8);
	}
	
%>
replaceInput("<%=ord_start_date_year%>","ord_start_date_year",__html);
replaceInput("<%=ord_start_date_month%>","ord_start_date_month",__html);
replaceInput("<%=ord_start_date_day%>","ord_start_date_day",__html);
replaceInput("<%=ord_end_date_year%>","ord_end_date_year",__html);
replaceInput("<%=ord_end_date_month%>","ord_end_date_month",__html);
replaceInput("<%=ord_end_date_day%>","ord_end_date_day",__html);

//2018.08.13 보험료 납부인수계약서 
replaceInput("<%=ord_start_date_year%>","start_work_date_year",__html);
replaceInput("<%=ord_start_date_month%>","start_work_date_month",__html);
replaceInput("<%=ord_start_date_day%>","start_work_date_day",__html);
replaceInput("<%=ord_end_date_year%>","end_work_date_year",__html);
replaceInput("<%=ord_end_date_month%>","end_work_date_month",__html);
replaceInput("<%=ord_end_date_day%>","end_work_date_day",__html);
replaceInput("<%=ContInfo.get("dept_name")%>","und_con_name",__html);//원도급공사명 
replaceInput("<%=ContInfo.get("CST_DOC_NAME")%>","sub_und_con_name",__html);//하도급공사
replaceInput("<%=ord_con_date_year%>","con_date_year",__html);
replaceInput("<%=ord_con_date_month%>","con_date_month",__html);
replaceInput("<%=ord_con_date_day%>","con_date_day",__html);

//나머지 계약정보
replaceInput("<%=ContInfo.get("DEPT_NAME")%>","dept_name",__html);//현장명
replaceInput("<%=ContInfo.get("DEALER_NM")%>","dealer_nm",__html);//발주처 2018.08.13 추가 
replaceInput("<%=ContInfo.get("CST_DOC_NAME")%>","cst_doc_name",__html);//계약명
replaceInput("<%=ContInfo.get("ORD_DOC_NO")%>","ord_doc_no",__html);// 계약번호
replaceInput("<%=ContInfo.get("CURR_STD")%>","curr_std",__html);// 통화단위
replaceInput("<%=ContInfo.get("CURR_STD_NM")%>","curr_std_nm",__html);// 통화단위
replaceInput("<%=ContInfo.get("LEAD_PLACE")%>","lead_place",__html);//공사장소
replaceInput("<%=ContInfo.get("ORD_AMT")%>","ord_amt",__html);// 계약금액

replaceInput("<%=ContInfo.get("LEAD_COND_GB")%>","lead_cond_gb"	,__html);
replaceInput("<%=ContInfo.get("LEAD_COND_GB_NM")%>","spn_lead_cond_gb"	,__html);
replaceInput("<%=ContInfo.get("ORD_SUPPLY_AMT")%>","ord_supply_amt"	,__html);
replaceInput("<%=ContInfo.get("ORD_SUPPLY_AMT")%>","ord_supply_amt2"	,__html);//2018.08.13 추가 
replaceInput("<%=ContInfo.get("ORD_SURTAX_AMT")%>","ord_surtax_amt"	,__html);
replaceInput("<%=ContInfo.get("PREPAY_AMT_RATE")%>","prepay_amt_rate"	,__html);
replaceInput("<%=ContInfo.get("PREPAY_AMT")%>","prepay_amt"	,__html);
replaceInput("<%=ContInfo.get("MID_AMT_RATE")%>","mid_amt_rate"	,__html);
replaceInput("<%=ContInfo.get("MID_AMT")%>","mid_amt"	,__html);
replaceInput("<%=ContInfo.get("RMDR_AMT_RATE")%>","rmdr_amt_rate"	,__html);
replaceInput("<%=ContInfo.get("RMDR_AMT")%>","rmdr_amt"	,__html);
replaceInput("<%=ContInfo.get("CON_GUAR_AMT_RATE")%>","con_guar_amt_rate"	,__html);
replaceInput("<%=ContInfo.get("CON_GUAR_TERM")%>","con_guar_term"	,__html);
replaceInput("<%=ContInfo.get("CON_GUAR_AMT")%>","con_guar_amt"	,__html);
replaceInput("<%=ContInfo.get("DEF_GUAR_AMT_RATE")%>","def_guar_amt_rate"	,__html);
replaceInput("<%=ContInfo.get("DEF_GUAR_AMT")%>","def_guar_amt"	,__html);
replaceInput("<%=ContInfo.get("DEF_GUAR_TERMS")%>","def_guar_terms"	,__html);
replaceInput("<%=ContInfo.get("DEF_GUAR_TERMS_TXT")%>","def_guar_terms_txt"	,__html);
replaceInput("<%=ContInfo.get("DEL_RATE_GB")%>","del_rate_gb"	,__html);
replaceInput("<%=ContInfo.get("PREPAY_GUAR_AMT_RATE")%>","prepay_guar_amt_rate"	,__html);
replaceInput("<%=ContInfo.get("PREPAY_GUAR_AMT")%>","prepay_guar_amt"	,__html);
replaceInput("<%=ContInfo.get("O_DIVISION")%>","req_dept_nm"	,__html);



replaceInput("<%=ContInfo.get("PREPAY_PAYMENT_NM")%>","prepay_payment_nm"	,__html);
replaceInput("<%=StringUtils.cvtHTML4(ContInfo.get("MID_PAYMENT_NM"))%>","mid_payment_nm"	,__html);
replaceInput("<%=StringUtils.cvtHTML4(ContInfo.get("RMDR_PAYMENT_NM"))%>","rmdr_payment_nm"	,__html);

replaceInput("<%=StringUtils.cvtHTML4(ContInfo.get("MID_PAYMENT_TXT"))%>","mid_payment_txt"	,__html);
replaceInput("<%=StringUtils.cvtHTML4(ContInfo.get("RMDR_PAYMENT_TXT"))%>","rmdr_payment_txt"	,__html);


replaceInput("<%=ContInfo.get("DEF_GUAR_TERMS2")%>","def_guar_terms2"	,__html);
replaceInput("<%=ContInfo.get("DEF_GUAR_TERMS_TXT2")%>","def_guar_terms_txt2"	,__html);

<%
if(params.get("TEMPLATE_CD").equals("3")){	//기자재공급계약서 선급금이 0ㅇ일경우 계약서에 3번내용을 안보이게 처리한다.
%>
	if("<%=ContInfo.get("PREPAY_AMT_RATE")%>" == "0"){
		chgPrepay("0");
	}
	
	if("<%=ContInfo.get("DEF_GUAR_TERMS2")%>"!=""||"<%=ContInfo.get("DEF_GUAR_TERMS_TXT2")%>"!=""){
		document.forms['form1']['check_guar'].checked = true;
		addGuar1(document.forms['form1']['check_guar']);
	}
	
	
<%
}
%>

/*발주서이면서 단가계약일 경우 공급가액, 부가세 , 총금액이 보이지 않고 수량과 단가만 나오도록 수정요청 2015-05-06*/
<%
if(params.get("TEMPLATE_CD").equals("4")){
%>
	if("<%=ContInfo.get("DIV_PO_YN")%>" == "Y"){
		divPoYn("Y");	
	}else{
	    divPoYn("N");
	}
<%	
}
%>
// 본사정보
replaceInput("<%=ContInfo.get("O_MEMBER_NAME")%>", "o_member_name", __html);
replaceInput("<%=ContInfo.get("O_ADDRESS")%>", "o_address", __html);
replaceInput("<%=ContInfo.get("O_TEL_NO")%>", "o_tel_no", __html);
replaceInput("<%=ContInfo.get("O_FAX_NO")%>", "o_fax_no", __html);
replaceInput("<%=ContInfo.get("O_BOSS_NAME")%>", "o_boss_name", __html);
replaceInput("<%=ContInfo.get("O_DIVISION")%>", "o_division", __html);
replaceInput("<%=ContInfo.get("O_USER_NAME")%>", "o_user_name", __html);
replaceInput("<%=ContInfo.get("O_POSITION")%>", "o_position", __html);
replaceInput("<%=ContInfo.get("O_TEL_NUM")%>", "o_tel_num", __html);
replaceInput("<%=ContInfo.get("O_HP")%>", "o_hp", __html);
replaceInput("<%=ContInfo.get("O_EMAIL")%>", "o_email", __html);
// 업체정보
replaceInput("<%=ContInfo.get("C_MEMBER_NAME")%>", "c_member_name", __html);
replaceInput("<%=ContInfo.get("C_ADDRESS")%>", "c_address", __html);
replaceInput("<%=ContInfo.get("C_BOSS_NAME")%>", "c_boss_name", __html);
replaceInput("<%=ContInfo.get("C_DIVISION")%>", "c_division", __html);
replaceInput("<%=ContInfo.get("C_USER_NAME")%>", "c_user_name", __html);
replaceInput("<%=ContInfo.get("C_POSITION")%>", "c_position", __html);
replaceInput("<%=ContInfo.get("C_TEL_NUM")%>", "c_tel_num", __html);
replaceInput("<%=ContInfo.get("C_HP")%>", "c_hp", __html);
replaceInput("<%=ContInfo.get("C_EMAIL")%>", "c_email", __html);

//한글로 변환할 금액, 금액 콤마처리
var f = document.forms["form1"];
if(f['kMoney']){
	var keyList = f['kMoney'].value.split(",");
	for(var keySeq = 0 ; keySeq < keyList.length ; keySeq ++){
		var key = keyList[keySeq];
		fSetKoreanMoney2(f[key].value, 'spn_'+key);
		replaceInput(fnMakeComma2(f[key].value),key,__html)
	}
}


<%if (params.get("ChgCont").equals("Y")) {		//변경 계약서 일경우 추가 내역%>
// 원 계약서 정보
	replaceInput("<%=ord_con_date_year%>","o_ord_con_date_year",__html);
	replaceInput("<%=ord_con_date_month%>","o_ord_con_date_month",__html);
	replaceInput("<%=ord_con_date_day%>","o_ord_con_date_day",__html);

	replaceInput("<%=ord_start_date_year%>","o_ord_start_date_year",__html);
	replaceInput("<%=ord_start_date_month%>","o_ord_start_date_month",__html);
	replaceInput("<%=ord_start_date_day%>","o_ord_start_date_day",__html);
	
	<%if (ContInfo.get("MOD_NO").equals("1")){%>
	replaceInput("원","o_title_text",__html);
	<%}else{%>
	replaceInput("이 전","o_title_text",__html);
	<%}%>
	
<%
String o_ord_end_date_year = ""; 
String o_ord_end_date_month = "";
String o_ord_end_date_day = "";
if(!OldContInfo.get("ORD_END_DATE").equals("")){
	o_ord_end_date_year = OldContInfo.get("ORD_END_DATE").replaceAll("-","").substring(0,4);
	o_ord_end_date_month = OldContInfo.get("ORD_END_DATE").replaceAll("-","").substring(4,6);
	o_ord_end_date_day = OldContInfo.get("ORD_END_DATE").replaceAll("-","").substring(6,8);
}
%>	
	replaceInput("<%=o_ord_end_date_year%>","o_ord_end_date_year",__html);
	replaceInput("<%=o_ord_end_date_month%>","o_ord_end_date_month",__html);
	replaceInput("<%=o_ord_end_date_day%>","o_ord_end_date_day",__html);

	//나머지 계약정보

	replaceInput("<%=ContInfo.get("MOD_NO")%>","spn_mod_no",__html);//변경차수
	replaceInput("<%=OldContInfo.get("DEPT_NAME")%>","o_dept_name",__html);//현장명
	replaceInput("<%=OldContInfo.get("CST_DOC_NAME")%>","o_cst_doc_name",__html);//계약명
	replaceInput("<%=OldContInfo.get("ORD_DOC_NO")%>","o_ord_doc_no",__html);// 계약번호
	replaceInput("<%=OldContInfo.get("LEAD_PLACE")%>","o_lead_place",__html);//공사장소
	replaceInput("<%=OldContInfo.get("ORD_AMT")%>","o_ord_amt",__html);// 계약금액
	
	replaceInput("<%=OldContInfo.get("LEAD_COND_GB")%>","o_lead_cond_gb"	,__html);
	/*발주서변수 예외처리*/
	if(document.forms['form1']['lead_cond_gb_01']){ 
		if("<%=OldContInfo.get("LEAD_COND_GB")%>"=="01"||"<%=OldContInfo.get("LEAD_COND_GB")%>"=="02"||"<%=OldContInfo.get("LEAD_COND_GB")%>"=="03"){
			document.forms['form1']['lead_cond_gb_<%=OldContInfo.get("LEAD_COND_GB")%>'].checked = true;
		}
	}
	replaceInput("<%=OldContInfo.get("ORD_SUPPLY_AMT")%>","o_ord_supply_amt"	,__html);
	replaceInput("<%=OldContInfo.get("ORD_SURTAX_AMT")%>","o_ord_surtax_amt"	,__html);
	replaceInput("<%=OldContInfo.get("PREPAY_AMT_RATE")%>","o_prepay_amt_rate"	,__html);
	replaceInput("<%=OldContInfo.get("PREPAY_AMT")%>","o_prepay_amt"	,__html);
	replaceInput("<%=OldContInfo.get("MID_AMT_RATE")%>","o_mid_amt_rate"	,__html);
	replaceInput("<%=OldContInfo.get("MID_AMT")%>","o_mid_amt"	,__html);
	replaceInput("<%=OldContInfo.get("RMDR_AMT_RATE")%>","o_rmdr_amt_rate"	,__html);
	replaceInput("<%=OldContInfo.get("RMDR_AMT")%>","o_rmdr_amt"	,__html);
	replaceInput("<%=OldContInfo.get("CON_GUAR_AMT_RATE")%>","o_con_guar_amt_rate"	,__html);
	replaceInput("<%=OldContInfo.get("CON_GUAR_TERM")%>","o_con_guar_term"	,__html);
	replaceInput("<%=OldContInfo.get("CON_GUAR_AMT")%>","o_con_guar_amt"	,__html);
	replaceInput("<%=OldContInfo.get("DEF_GUAR_AMT_RATE")%>","o_def_guar_amt_rate"	,__html);
	replaceInput("<%=OldContInfo.get("DEF_GUAR_AMT")%>","o_def_guar_amt"	,__html);
	replaceInput("<%=OldContInfo.get("DEF_GUAR_TERMS")%>","o_def_guar_terms"	,__html);
	replaceInput("<%=OldContInfo.get("DEL_RATE_GB")%>","o_del_rate_gb"	,__html);
	replaceInput("<%=OldContInfo.get("CON_GB")%>","con_gb"	,__html);
	
	replaceInput("<%=OldContInfo.get("PREPAY_PAYMENT_NM")%>","o_prepay_payment_nm"	,__html);
	
	replaceInput("<%=StringUtils.cvtHTML4(OldContInfo.get("MID_PAYMENT_NM"))%>","o_mid_payment_nm"	,__html);
	replaceInput("<%=StringUtils.cvtHTML4(OldContInfo.get("RMDR_PAYMENT_NM"))%>","o_rmdr_payment_nm"	,__html);

	replaceInput("<%=OldContInfo.get("MID_PAYMENT_TXT")%>","o_mid_payment_txt"	,__html);
	replaceInput("<%=OldContInfo.get("RMDR_PAYMENT_TXT")%>","o_rmdr_payment_txt"	,__html);

	replaceInput("<%=ContInfo.get("MID_PAYMENT_TXT")%>","mid_amt_txt"	,__html);
	replaceInput("<%=OldContInfo.get("RMDR_PAYMENT_TXT")%>","rmdr_payment_txt"	,__html);
	
	

<% } %>

if(f['comma']){
	var keyList = f['comma'].value.split(",");
	for(var keySeq = 0 ; keySeq < keyList.length ; keySeq ++){
		var key = keyList[keySeq];
		replaceInput(fnMakeComma2(f[key].value),key,__html)
	}
}
</script>

<script>
//window.addEventListener("onload",convertHtml)
//window.onload=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>

<%//상품 목록 %>
<%if (params.get("ChgCont").equals("Y")) {		//변경 계약서 일경우 추가 내역%>
	<%@ include file="/jsp/ko_KR/buyer/cont/purchase/chgItemList.jsp" %>
<%}%>

<%@ include file="/jsp/ko_KR/buyer/cont/purchase/itemList.jsp" %>