<%--
  - Author(s)  : mklee
  - Date       : 2017.07.06
  - Description: 외주_하도급대금지급보증서 
  --%>
  
<%@ page contentType="text/html; charset=utf-8" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.util.Date" %>
<%@ page import="com.udapsoft.waf.system.HandlerStorage" %>
<%@ page import="com.udapsoft.waf.common.ui.*" %>
<%@ page import="kr.co.udapsoft.common.code.*" %>
<%@ page import="kr.co.hsnc.common.util.*"%>
<%@ page import="kr.co.hsnc.common.sql.*" %>
<%@ page import="com.udapsoft.waf.common.util.Formatter2"%>
<%@ page import="com.udapsoft.waf.common.util.StringUtils"%>
<%@ include file="/jsp/work/taglib.jsp" %>
<%@ page import="kr.co.hsnc.common.config.WAFConfig %>
<jsp:useBean id="ctx" class="com.udapsoft.waf.system.context.SessionContext" scope="session" />
<%
    String guarUrl = WAFConfig.get("waf.guar.url");

    ctx.init(request, response);
    HandlerStorage storage = ctx.getHandlerStorage();
    ValueObject params = storage.getParams();
    ValueObject user = storage.getUser();
    ValueObject cont = storage.getValueObject("Cont");
    ValueObject guar = storage.getValueObject("guar");
 %>
<SCRIPT language="JavaScript">
    document.body.onresize = addEvent( document.body.onresize, "autoResize()");
	/*예약함수*/
	var sheet1 = new ibsheetObject();
	var sheet2 = new ibsheetObject();
	var sheet1Row;
	var sheet1PageNo = 1;
	var sheet2Row;
	var sheet2PageNo = 1;
	var pageLastRowIndex = 1;
	var validationResult = false;
	var filterShow = false;
	

	function _onReady(){
		
		/**
		 *	IBSheet object initialize
		 */
		gridInit(sheet1);
		gridInit(sheet2);
		
		/**
		 *	Application Initialize
		 */
		 jQuery("#btn_list").click(function() {
				$("#fevent").val("");
				$("#form1").attr("action", "/cont/purchase/SubconPayGuarList.screen");
				$("#form1").attr("target", "_self");
				$("#form1").attr("method", "post");
				
				$("#form1").submit();
		 });
		 jQuery("#btn_save").click(function() {
			    var f = document.form1;
				jQuery("#fevent").val("GUAR_SAVE");
				submitXmlRequest("/cont/purchase/SubconPayGuarDetail_form.screen", "GUAR_SAVE", f, "SUCCESS");
		 });
		 jQuery("#CON_AMT,#ADDPREPAYAMT,#FILESIZE").blur(function () {
			 doCalculation();		 
		 });
		 jQuery("#START_WORK_DATE, #END_WORK_DATE").change(function(){
			 doCalculation();	 
		 });
		 <% if (!guar.get("WARR_STATUS").equals("완료")) {%>
		 	doCalculation();
		 <%}else {%>
		    var s_date =  new Date(jQuery("#START_WORK_DATE").val().substring(0,4),jQuery("#START_WORK_DATE").val().substring(5,7) - 1,jQuery("#START_WORK_DATE").val().substring(8,10) ) ;//공사기간
		 	var end_date = new Date(jQuery("#END_WORK_DATE").val().substring(0,4),jQuery("#END_WORK_DATE").val().substring(5,7) -1,jQuery("#END_WORK_DATE").val().substring(8,10)) ;
			var diff = end_date - s_date;
			var curDay = 24*60*60*1000 ;
			var curMonth = curDay * 30;
			var curYear = curMonth * 12;		
			var duration = parseInt(diff/curDay) + Number(1);
			var cal_date = Number(duration) / 30;
			jQuery("#dur_date").val("(공사기간 " + duration + "일)");			
		 <%}%>
         doSearchSheet1();
	}
	
	function doCalculation(){ 
		var conamt = jQuery("#CON_AMT").val().replace(/(\,|\:)/g,"");  //계약금액
		var preamt = jQuery("#ADDPREPAYAMT").val().replace(/(\,|\:)/g,"");  //계약상선급금 
		var paymon = jQuery("#FILESIZE").val().replace(/(\,|\:)/g,"");  //기성지급주기 
		var warramt = Number(conamt) - Number(preamt)  ; //보증금액 
		var s_date =  new Date(jQuery("#START_WORK_DATE").val().substring(0,4),jQuery("#START_WORK_DATE").val().substring(5,7) - 1,jQuery("#START_WORK_DATE").val().substring(8,10) ) ;//공사기간
	 	var end_date = new Date(jQuery("#END_WORK_DATE").val().substring(0,4),jQuery("#END_WORK_DATE").val().substring(5,7) -1,jQuery("#END_WORK_DATE").val().substring(8,10)) ;
		var diff = end_date - s_date;
		var curDay = 24*60*60*1000 ;
		var curMonth = curDay * 30;
		var curYear = curMonth * 12;		
		var duration = parseInt(diff/curDay) + Number(1);
		var cal_date = Number(duration) / 30;
		jQuery("#dur_date").val("(공사기간 " + duration + "일)");
		
		if (Number(duration) < 121){   //공사기간 4개월이하. 기성지급주기 2개월 이하 : 보증금액=하도급계약금액 - 계약상 선급금 
			warramt = Number(conamt) - Number(preamt)
		}else{
			if (Number(paymon) < 3) {  //기성지급주기 2개월 이하 : ((계약금액-선급금)/(공사일수/30)) * 4
				warramt = Math.floor(Number(warramt)/Number(cal_date)*4); 
			}else{ //기성지급주기 2개월 초과 : ((계약금액-선급금)/(공사일수/30)) * 기성지급주기 * 2
				warramt = Math.floor((Number(warramt)/Number(cal_date)) * Number(paymon) * 2); 
			}				
		}
		warramt =  Math.floor(warramt / 10 ) * 10;
		jQuery("#WARR_WAMT").val(warramt);
		
		jQuery("#WARR_WAMT").each(function(index){
			jQuery(this).val(jQuery(this).val().split(/(?=(?:\d{3})+(?:\.|$))/g).join(','));
		});
	}
	
	function doSearchSheet1(){
		$("#fevent").val("GUAR_SHEET");
		var url = Modular.model.PageContext.CONTEXT_ROOT + "/cont/purchase/SubconPayGuarDetail_sheet.screen";
		Modular.view.IBSheet7.doSearch(sheet1, url, jQuery("#form1"), 30, "");
	}
	function doSearchSheet2(){
		$("#fevent").val("PAYMENT_SHEET");
		var url = Modular.model.PageContext.CONTEXT_ROOT + "/cont/purchase/SubconPayGuarDetail_sheet.screen";
		Modular.view.IBSheet7.doSearch(sheet2, url, jQuery("#form1"), 30, "");
	}
	function popContWarr(wG, wSeq, wCauseCd, wOnOff, wGStatus, wOffid, wConRefNo) {
		var win_id = "subconPayPurOffPopup";			
		var param = "";
		var param = "?purContModId=" + jQuery("#PUR_CONT_MOD_ID").val();
		var param = param + "&warrGubun=" + wG;
		var param = param + "&warrSeq=" + wSeq;
		var param = param + "&causeCode=" + wCauseCd;
		var param = param + "&viewDiv=SUBCONPAY";
		var param = param + "&pop_win_id=" + win_id;
		var url = "";

		if (wOnOff == ""){
			alert("발급구분을 선택해 주세요.");return;
		}
		if(wOnOff=="N"){
			var param = param + "&fevent=WARR_OFF";
			url = "/portal/guar/subconPayPurOffPopup.screen"+param;			
			fLayerPop(win_id, url, 560,500, '','', 'YES');
		}else if(wOnOff=="Y"){
			if((wGStatus=="08") || (wGStatus=="09")){
				var	sGuarKind		=	wG;														//보증서종류
				var	sGuarSeq		=	wSeq;															//일련번호
				var	sGuarOnoffYn	=	wOnOff;												//온오프여부
				var	sGuarStatus		=	wGStatus;													//보증진행상태
				var	sChgNo			=	jQuery("#MOD_NO").val();	//계약차수
				var	style			=	"";
				var	src				=	"";
				var	sGrtType	=	"006";	//	보증종목구분 : 지급
				//검토대기나 완료일경우
				if(sGuarOnoffYn == "Y" && sGuarStatus.length > 0 && (sGuarStatus == "08" || sGuarStatus == "09")){
					var	sOffId				=	wOffid;		//	수신기관 ID
					var	conRefNo			=	wConRefNo; 							//	계약번호
					var	sGrtSeq				=	wSeq;	//	보증차수			
					var	sMsgFuncCode		=	"53";																//	문서기능
					var	sModule				=	"EB";																//	모듈구분코드
					
					if(sChgNo == "")	
						sChgNo	=	"00";
					else if(sChgNo.length == 1)
						sChgNo = "0" + sChgNo;
						
					if(sGrtSeq.length == 1)
						sGrtSeq = "0" + sGrtSeq;
						
					//parameter 확인 요함
					src		= "<%=guarUrl%>/transure/view/KSCFCView.jsp?offID="+sOffId+"&conRefNo="+conRefNo+"&conSeqNo="+sChgNo+"&grtSeq="+sGrtSeq+"&grtType="+sGrtType+"&msgFuncCode="+sMsgFuncCode+"&module="+sModule;
					style	=	"width=720,height=800, loactionbar=visible, menubar=visible, scrollbars=no";
				}
				//alert(src);
				var	id		=	"WARR";		
				var	clNew	=	window.open(src,id,style);
				
				if(clNew == null){
					alert("          ▒【보증신청】페이지는 팝업창으로 구성되어 있습니다. ▒\n\n\n'팝업이 차단되었습니다. 팝업 또는 추가 옵션을 보려면 여기를 클릭하십시오.' 라는\n\n 메세지가 보일경우에는 그 메세지를 클릭하셔서 '현재 사이트의 팝업을 항상 허용'이나\n\n'임시로 팝업허용'으로 설정해주시기 바랍니다.");
				}else{
					clNew.focus();
				}				
			}else{		//온라인 처음 등록
				var param = param + "&fevent=WARR_ON";
				var param = param + "&PUR_CONT_ID=" + jQuery("#PUR_CONT_ID").val();
				var param = param + "&MOD_NO=" + jQuery("#MOD_NO").val();
				url = "/portal/guar/subconPayPurOnPopup.screen"+param;			
				fLayerPop(win_id, url, 800,700, '','', 'YES');				
			}
		}	
	}	
	//보증정보팝업 종료후 액션
	function popContWarrClose(returnValue){
		if(returnValue == null){
			fLayerPopClose('subconPayPurOffPopup');
		}else{
			if(returnValue[0] == 0){
				fLayerPopClose('subconPayPurOffPopup');
				var f = document.form1;
			    f.isSubmit = false;
				$("#PUR_CONT_MOD_ID").val(returnValue[2]);
				reDisplay(); 
			}
		}
	}
	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="Y";}else{editFile="Y";}
			if(No=="1"){
				viewFileListNew(fileGB, obj.value, fObj.p_AttachFileGuar1, editFile, fileDir, "subconPayPurOffPopup");
			}else{
				viewFileListNew(fileGB, obj.value, fObj.p_AttachFileGuar2, editFile, fileDir, "subconPayPurOffPopup");
			}
		} 
	} 
	/**
	 *	IBSheet object initialize
	 */
	function gridInit(sheetName){
		var init_sheet = {};
		init_sheet.Cfg = {SearchMode:2, Page:30,MergeSheet:msHeaderOnly};
		if(sheetName.id == "sheet1"){
			init_sheet.Cols = [
								{Header:'변경구분',				Type:"Text", 			SaveName:"CAUSECODE_NM", 		Width:100, 		Align:"Left" , 		Edit:"false"},
								{Header:'증서번호',				Type:"Text", 			SaveName:"WARR_WGNO", 			Width:150, 		Align:"Left" , 		Edit:"false"},
								{Header:'발급기관',				Type:"Text", 			SaveName:"WARR_GOFFICE", 		Width:150, 		Align:"Left" , 		Edit:"false"},
								{Header:'보증금액',				Type:"Text", 			SaveName:"WARR_WAMT", 			Width:100, 		Align:"right", 		Edit:"false"},
								{Header:'수수료',				Type:"Text", 			SaveName:"WARR_COMMSN", 		Width:100, 		Align:"right",		Edit:"false"},
								{Header:'보증기간',				Type:"Text", 			SaveName:"WARR_START_END_DATE",	Width:150, 		Align:"Center", 	Edit:"false"},
								{Header:'발급일',				Type:"Text", 			SaveName:"PAPERDATE", 			Width:80,		Align:"Center",		Edit:"false"},
								{Header:'발급구분',				Type:"Combo", 			SaveName:"GUAR_ONOFF_YN", 		Width:80, 		Align:"Center" , 	Edit:"true", 	ComboText:"선택|온라인|오프라인|비대상", ComboCode:"|Y|N|F"},
								{Header:'진행상태',				Type:"Text", 			SaveName:"GUAR_STATUS_NM", 		Width:80, 		Align:"center", 	Edit:"false"},
								{Header:'보증신청계약번호',		Type:"Text", 			SaveName:"GRTREQNO", 			Width:100,  	Align:"Left", 		Edit:"false"},
								{Header:'PUR_CONT_MOD_ID',	Type:"Text", 			SaveName:"PUR_CONT_MOD_ID", 	Width:0, 		Align:"Center",		Hidden:"True"},
								{Header:'WARR_GUBUN',		Type:"Text", 			SaveName:"WARR_GUBUN", 			Width:0, 		Align:"Center",		Hidden:"True"},
								{Header:'WARR_SEQ',			Type:"Text", 			SaveName:"WARR_SEQ", 			Width:0, 		Align:"Center",		Hidden:"True"},
								{Header:'CAUSECODE',		Type:"Text", 			SaveName:"CAUSECODE", 			Width:0, 		Align:"Center",		Hidden:"True"},
								{Header:'보증등록',				Type:"Image", 			SaveName:"BTN", 				Width:80, 		Align:"Center", 	Edit:"false",	Cursor:"Pointer"},
								{Header:'비고',				Type:"Text", 			SaveName:"WARR_GREM", 			Width:100, 		Align:"Left", 		Edit:"false"},
								{Header:'Status',			Type:"Status", 			SaveName:"STATUS", 				Width:50, 		Align:"Center",		Hidden:"True"},
								{Header:'진행상태',				Type:"Text", 			SaveName:"GUAR_STATUS", 		Width:50, 		Align:"Center",		Hidden:"True"},
								{Header:'수신기관',				Type:"Text", 			SaveName:"WARR_GOFFICE_ID", 	Width:50, 		Align:"Center",		Hidden:"True"},
		                    ];
			
			init_sheet.HeaderMode = {Sort:1};
			IBS_InitSheet(sheetName, init_sheet);
			sheetName.SetDataAutoTrim(0);
			sheetName.SetImageList(1,"/img/buyer/btn/btn_write.gif");
			sheetName.SetImageList(2,"/img/buyer/btn/error_detail_plus.gif"); 
		}else{
			init_sheet.Cols = [
				    			{Header:'상태|상태',					Type:"Status", 			SaveName:"Status",					Width:100, 	Align:"Left", Hidden:"True"},
				    			{Header:'현장명|현장명',				Type:"Text", 			SaveName:"DEPT_NAME",				Width:100, 	Align:"Left"},
				    			{Header:'계약번호|계약번호',				Type:"Text", 			SaveName:"CON_DOC_NO",				Width:120, 	Align:"Left", Hidden:"True"},
				    			{Header:'계약명|계약명',				Type:"Text", 			SaveName:"BUILD_NAME",				Width:110, 	Align:"Left"},
				    			{Header:'업체명|업체명',				Type:"Text", 			SaveName:"MEMBER_NAME",				Width:100, 	Align:"Left"},
				    			{Header:'공사기간|공사기간',				Type:"Text", 			SaveName:"START_END_WORK_DATE", 	Width:130, 	Align:"Left"},
				    			{Header:'통화구분|통화구분',				Type:"Text", 			SaveName:"CURRENCY_GB",				Width:55, 	Align:"Center"},
				    			{Header:'통화구분자리|통화구분자리',		Type:"Int", 			SaveName:"CURRENCY_DIGIT",			Width:100, 	Align:"Left", Hidden:"True"},
				    			{Header:'계약금액|계약금액',				Type:"Int", 			SaveName:"CON_SUPPLY_AMT",	 		Width:80, 	Align:"Right"},
				    			{Header:'계약금액|합계',				Type:"Int", 			SaveName:"CON_AMT", 				Width:40, 	Align:"Right", Hidden:"True"},
				    			{Header:'계약상선급금|계약상선급금',		Type:"Int", 			SaveName:"PREPAY_SUPPLY_AMT",	 	Width:80, 	Align:"Right"},
				    			{Header:'선급금발생|선급금발생',			Type:"Int", 			SaveName:"REQ_PREPAY_SUPPLY_AMT",	Width:80, 	Align:"Right"},
				    			{Header:'선급금\n신청날짜|선급금\n신청날짜',Type:"Text", 			SaveName:"PREPAY_DATE",	 			Width:65, 	Align:"Right"},
				    			{Header:'기성년월|기성년월',				Type:"Text", 			SaveName:"ACMP_YYYYMM",	 			Width:50, 	Align:"Right"},
				    			{Header:'지급\n차수|지급\n차수',			Type:"Int", 			SaveName:"ACMP_NO",	 				Width:40, 	Align:"Right"},
				    			{Header:'기성액|금회기성',				Type:"Int", 			SaveName:"FUND_AMT",	 			Width:80, 	Align:"Right"},
				    			{Header:'기성액|선급금공제',				Type:"Int", 			SaveName:"PAY_DEDUCT_AMT",	 		Width:80, 	Align:"Right"},
				    			{Header:'기성액|실지불액',				Type:"Int", 			SaveName:"REQU_SUPPLY_AMT",	 		Width:80, 	Align:"Right"},
				    			{Header:'기성액|잔여기성',				Type:"Int", 			SaveName:"MOD_FUND_AMT",	 		Width:80, 	Align:"Right"},
				    			{Header:'기성율\n(%)|기성율\n(%)',		Type:"Float", 			SaveName:"FUND_RATE",	 			Width:40, 	Align:"Right",	Format:"##0.00"},
				    			{Header:'상태|상태',					Type:"Text", 			SaveName:"STATUS_CD",	 			Width:50, 	Align:"Center"},
			];
			
			init_sheet.HeaderMode = {Sort:1};
			IBS_InitSheet(sheetName, init_sheet);
			sheetName.SetDataAutoTrim(0);
			sheetName.SetEditable(false);
			
			var info = [{StdCol:1, SumCols:"CON_AMT|FUND_AMT", ShowCumulate:0,Sort:0,CaptionCol:1}
		    ,{StdCol:2, SumCols:"CON_AMT|FUND_AMT|PAY_DEDUCT_AMT|REQU_SUPPLY_AMT|FUND_RATE", ShowCumulate:0,Sort:0,CaptionCol:2}];
			sheetName.ShowSubSum(info);
			sheetName.SetActionMenu("ExcelDown");
			
		}
		setGridSize();
	}
	
	/**
	 *	IBSheet Event: Search End(IBSheet 데이터 조회 CallBack)
	 */
	function sheet1_OnSearchEnd(code, message) {
		 var fevent = $("#fevent").val();
		 if(code == 0) {
			if("GUAR_SHEET" == fevent){
	    		doSearchSheet2(); 
	    	}	    		
		} else {
			//조회 에러 수행
			alert(message);
		}
	}
	
	/**
	 *	IBSheet Event: Search End(IBSheet 데이터 조회 CallBack)
	 */
	function sheet2_OnSearchEnd(code, message) {
		 var fevent = $("#fevent").val();
		 if(code == 0) {
			 if ($("#WARR_WAMT").val() == ""){
				 doCalculation();	
			 }
		 } else {
			//조회 에러 수행
			alert(message);
		}
	}
	function sheet1_OnDblClick(Row, Col, Value, CellX, CellY, CellW, CellH) {
		 if ((sheet1.ColSaveName(Col) == "BTN")) {
			 var comboValue = sheet1.GetCellValue(Row,"GUAR_ONOFF_YN");
			if(comboValue == "F" ){
				var Status = sheet1.GetCellValue(Row,"STATUS");
				if(Status=="R"){
					alert("변경된 데이터가 없습니다.");
					return;
				}
				var bigo = sheet1.GetCellValue(Row,"WARR_GREM");;
				if(bigo == "" || bigo == null){
					alert("비대상 사유를 비고란에 입력하세요");
					return;
				}
				if(!confirm("비대상 보증정보를 저장하시겠습니까?")) return;
				
				jQuery("#fevent").val("NOT_GUAR_SAVE");
				var url = Modular.model.PageContext.CONTEXT_ROOT + "/cont/purchase/SubconPayGuarList_sheet.screen";
				var result = Modular.view.IBSheet7.doSave(sheet1, url, jQuery("#form1"), false);	
				
			}else{
				 popContWarr(sheet1.GetCellValue(Row, "WARR_GUBUN"),sheet1.GetCellValue(Row, "WARR_SEQ"),sheet1.GetCellValue(Row, "CAUSECODE"),sheet1.GetCellValue(Row, "GUAR_ONOFF_YN"),sheet1.GetCellValue(Row, "GUAR_STATUS"),sheet1.GetCellValue(Row, "WARR_GOFFICE_ID"),sheet1.GetCellValue(Row, "GRTREQNO"))
			}			 
		}
	}
	/**
	 *	IBSheet size setting
	 */
	function setGridSize() {
		sheet1.FitColWidth();
		sheet2.FitColWidth();
	}
	
	function doResult(resultObj) {
		try {
			if( resultObj.getRequestEvent() == "FORM_UPDATE") {
				if( resultObj.getSuccess() ) {
					alert("저장 되었습니다.");
 					$("#btn_list").click();
				}
				else {
					dlgErrorMsg(resultObj);
				}
			}else if( resultObj.getRequestEvent() == "GUAR_SAVE" ) {
				if( resultObj.getSuccess() ) {				
					document.form1.isSubmit = false;
					alert("저장되었습니다.");		
					reDisplay();
				}else {
					dlgErrorMsg(resultObj);
				}
			}
		} catch(errorObject) {
			showErrorDlg("doResult()", errorObject);
		}
	}
	
	function sheet1_OnSmartResize(Width, Height) { 
		setGridSize();
		autoResize();
	}

	function autoResize(){
		sheet1.SetSheetHeight(160); 
		sheet2.SetSheetHeight(250);
	}
    function reDisplay() {
		
		jQuery("#fevent").val("UPDATE_DATA");
		jQuery("#form1").attr("action", "/cont/purchase/SubconPayGuarDetail.screen");
		jQuery("#form1").attr("target", "_self");
		jQuery("#form1").attr("method", "post");
		jQuery("#form1").submit();
		
	}
    function doSignFile(){
	    var job_div = "O";
		var popUrl = "/payment/purchase/PayItemOutDashBoardPop.screen?job_div="+job_div+"&sModule=LM&purContId="+ jQuery("#PUR_CONT_ID").val()+"&job_auth=<%= user.get("RIGHT_NAME")%>";
		job_div = "O";
		var popOption = "width=800, height=600, resizable=no, scrollbars=yes, status=no;";
		window.open(popUrl,"",popOption);
	}
</SCRIPT>


<modular:search id="form1">
	<modular:key id="fevent" />
</modular:search>
<BODY onresize="autoResize()">
<form id="form1" name="form1" method="post" modular:type="search">

<INPUT type='hidden' name="fevent" id="fevent"  value="">
<!-- List Search -->
<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_build_nm" value="<%=params.get("p_build_nm")%>">
<INPUT type='hidden' name="p_dealer_nm" value="<%=params.get("p_dealer_nm")%>">
<INPUT type='hidden' name="ContFromDt" value="<%=params.get("ContFromDt")%>">
<INPUT type='hidden' name="ContToDt" value="<%=params.get("ContToDt")%>">
<!-- List Search -->  
<INPUT type='hidden' name="PUR_CONT_MOD_ID" value="<%=cont.get("PUR_CONT_MOD_ID")%>">
<INPUT type='hidden' name="PUR_CONT_ID" value="<%=cont.get("PUR_CONT_ID")%>">
<INPUT type='hidden' name="MOD_NO" value="<%=cont.get("MOD_NO")%>"> 
<INPUT type='hidden' name="WARR_GUBUN" value="2"> 
<INPUT type='hidden' name="WARR_SEQ" value="<%=guar.get("WARR_SEQ")%>">  
<INPUT type='hidden' name="CAUSECODE" value="<%=cont.get("CAUSECODE")%>"> 
 		
<table width="100%">
	<colgroup>
		<col width="500" />
		<col width="*" />
	</colgroup>
	<tr>
   		<th>
			<div align="left" id="title">
			    <ul><li>구매_하도급대금지급보증 상세<font style="font-size:11px"> </font></li></ul>
			</div> 
   		</th>
   		<td align="right">
				<span class="btnSearch center" id="btn_list"><a href="javascript:void(0);">목록</a></span>
   		</td>
  	</tr>
</table>


<div class="application-info magT10">
	<div class="application-sub-title">
		<span class="title">계약정보</span>
	</div>
</div>

<!-- 발주의뢰정보 : 시작 -->

<TABLE class="form-table">
	<colgroup>
		<col width="160"/>
		<col width="20%">
		<col width="160"/>
		<col width="20%">
		<col width="160"/>
		<col/>
	</colgroup>
  <TR height="25"> 
    <TH> 현장</TH>
	<TD><%=cont.get("DEPT_NAME") %></TD>
	<TH> 계약번호</TH>
	<TD><a href="javascript:doSignFile();"><%=cont.get("CON_DOC_NO")%></a>
	</TD>
	<TH> 계약명</TH>
	<TD><%=cont.get("BUILD_NAME")%></TD>
  </TR>

  <TR height="25"> 
	<TH> 업체명</TH>
	<TD><%= cont.get("MEMBER_NAME")%></TD>
	<TH> 공사기간</TH>
	<TD><%= cont.get("START_WORK_DATE")%> ~ <%= cont.get("END_WORK_DATE")%></TD>
	<TH> 계약금액</TH>
	<TD><%= cont.get("CON_AMT")%></TD> 	
  </TR>
  
  <TR height="25"> 
	<TH> 계약일자</TH>
	<TD><%=cont.get("CON_DATE") %></TD>
	<TH> 발급여부</TH>
	<TD><%= guar.get("WARR_STATUS") %></TD> 	
	<TH> 변경구분</TH>   
	<TD><%=Formatter2.currency(cont.get("CAUSECODE_NM"),0) %></TD>
  </TR> 	
    
  <!-- 계약정보 : 종료 -->
</table>

<table id=item_list width="100%">
	<colgroup>
		<col width="500" />
		<col width="*" />
	</colgroup>
	<tr>
   		<th>
   		<div class="application-info magT20">
			<div class="application-sub-title">
				<span class="title">잔여기성 검색</span>
			</div>
		</div>
   		</th>
   		<td align="right">
   		</td>
  	</tr>
</table>
<div id="sheet2_div" style="padding-top:5px;height: auto; min-height: 250px; overflow: auto;">
	<script>createIBSheet('sheet2','100%', '250px');</script>
</div>
	

<table width="100%" id="corp_list_title">
	<colgroup>
		<col width="500" />
		<col width="*" />
	</colgroup>
	<tr>
   		<th>
   		<div class="application-info magT15">
			<div class="application-sub-title">
				<span class="title">보증금 계산</span>
			</div>
		</div>
   		</th>
   		<td align="right">	
   		<% if (!guar.get("WARR_STATUS").equals("완료")) {%>
   				<span class="btnSearch center" id="btn_save"><a href="javascript:void(0);">저장</a></span> 
   	   <% }%>
   		</td>
  	</tr>
</table>

<!-- 발주의뢰정보 : 시작 -->

<TABLE class="form-table">
	<colgroup>
		<col width="160"/>
		<col width="20%">
		<col width="160"/>
		<col width="20%">
		<col width="160"/>
		<col/>
	</colgroup>
  <TR height="25"> 
    <TH> 계약금액</TH>
	<TD><%= InputText.get("CON_AMT", Formatter2.currency(guar.get("CON_AMT"),0), 13, 300, "Right,Number","Number") %></TD> 
	<TH> 공사시작일</TH>
	<TD>  <%= InputText.get("START_WORK_DATE", guar.get("START_WORK_DATE"), 10, 10, "desc=계약일자,center,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');">
	</TD>
	<TH> 계약이행(준공)일</TH>
	<TD><%= InputText.get("END_WORK_DATE", guar.get("END_WORK_DATE"), 10, 10, "desc=준공일자,center,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');">
	<INPUT type='text' name="dur_date" value="" size="40" style="border: 0px;" readonly> 
	</TR>

  <TR height="25"> 
	<TH> 대금지급주기</TH>
	<TD><%= InputText.get("FILESIZE", Formatter2.currency(guar.get("FILESIZE"),0), 1, 30, "Right,Number","Number") %>개월마다 1회</TD>
	<TH> 계약상선급금<p>(미정산선급)</TH>
	<TD><%= InputText.get("ADDPREPAYAMT", Formatter2.currency(guar.get("ADDPREPAYAMT"),0), 13, 300, "Right,Number","Number") %></TD>
	<TH> 보증금액</TH>
	<TD><%= InputText.get("WARR_WAMT", Formatter2.currency(guar.get("WARR_WAMT"),0), 13, 300, "Right,Number","Number") %></TD> 	
  </TR>
  
  <!-- 보증금 계산 : 종료 -->
</table>
	
<div class="application-info magT10">
	<div class="application-sub-title">
		<span class="title">보증서첨부</span>
	</div>
</div>
	<div id="sheet1_div" style="padding-top:5px;height: auto; min-height: 160px; overflow: auto;">
		<script>createIBSheet('sheet1','100%', '160px');</script>
	</div>
</form>
