<%--
  - FileName   : 
  - Author(s)  : 
  - Date       : 
  -
  - Description: 한국소방시설협회 실적증명서
  --%>



<%@ page contentType="text/html; charset=utf-8"%>
<%@ page import="com.udapsoft.waf.system.HandlerStorage"%>
<%@ page import="com.udapsoft.waf.common.ui.*"%>
<%@ page import="kr.co.hsnc.common.util.*"%>
<%@ page import="kr.co.hsnc.common.sql.*"%>
<%@page import="java.net.URLEncoder"%>
<%@ page import="com.udapsoft.waf.common.util.StringUtils"%>
<%@ include file="/jsp/work/taglib.jsp"%>
<jsp:useBean id="ctx"
	class="com.udapsoft.waf.system.context.SessionContext" scope="session" />
<%
	ctx.init(request, response);
	HandlerStorage storage = ctx.getHandlerStorage();
	ValueObject params = storage.getParams();
	ValueObject user = storage.getUser();

	ValueObject vo = storage.getValueObject("ResultDetail03BizVo");
	RowSet fileRowSet = storage.getRowSet("RESULT_PDF");

	String pageEvent = storage.getEvent();
%>
<script language="javascript" src="/js/report.js"></script>
<script type="text/javascript">
<!--

	$(document).on("keyup", "input:text[numberOnly]", function() 
   	{
   	    $(this).val( $(this).val().replace(/[^0-9]/gi,"") );		//숫자만입력 정규식...
   	    $(this).val($(this).val().split(/(?=(?:\d{3})+(?:\.|$))/g).join(','));  //콤마찍기 정규식...귀찮ㄹ타
   	 });
   	 
   	$(document).on("keyup", "input:text[number]", function() 
   	{
  	    $(this).val( $(this).val().replace(/[^0-9]/gi,"") );		//숫자만입력 정규식...
   	 });
   	
   	

	$(function(){
	    
	    $.gridInit = function()
		{
	        var init_sheet = {};
	        init_sheet.Cfg = {SearchMode:2, MergeSheet:msHeaderOnly, Page:10};
			
			init_sheet.Cols = [
										{Header:"삭제",								Type:"DelCheck",					SaveName:"DEL_CHECK", 				Width:15, 		Align:"Center"},
										{Header:'Status',								Type:"Status", 					SaveName:"STATUS", 					Width:0, 	Align:"Center", Edit:"False", Hidden:"True"},
										{Header:"SEQ",	 							Type:"Text", 						SaveName:"SEQ",							Width:80, 	 Align:"Center", Hidden:"True"},
										{Header:"PUR_CONT_MOD_ID",	 		Type:"Text", 						SaveName:"PUR_CONT_MOD_ID",	Width:80, 	 Align:"Center", Hidden:"True"},
										{Header:"ACMP_YYYY",	 					Type:"Text", 						SaveName:"ACMP_YYYY",				Width:80, 	 Align:"Center", Hidden:"True"},
										{Header:"SOC_CD",	 						Type:"Text", 						SaveName:"SOC_CD",					Width:80, 	 Align:"Center", Hidden:"True"},
										{Header:"제출협회",	 		                Type:"Combo", 			    SaveName:"SUB_SOC_CD",			    Width:80, 	    Align:"Center", ComboText:"대한전문건설협회|대한기계설비공사협회|한국소방시설협회|한국정보통신공사협회|한국전기공사협회", ComboCode:"01|02|03|04|05", KeyField:"True", Edit:"True"},
										{Header:"공사(종)명",	 						Type:"Text", 						SaveName:"CONT_NM",					Width:80, 	 Align:"Left", KeyField:"True"},
										{Header:"도급금액",	 					Type:"AutoSum", 					SaveName:"SCONT_AMT",				Width:80, 	 Align:"Right", Format:"#,##0", KeyField:"True"},
										{Header:"전년도까지 기성액",				Type:"AutoSum", 					SaveName:"PRV_PAY_AMT",			Width:80, 	 Align:"Right", Format:"#,##0" },
										{Header:"금년도 기성액",	 					Type:"AutoSum", 					SaveName:"CUR_PAY_AMT",			Width:80, 	 Align:"Right", Format:"#,##0", KeyField:"True"},
										{Header:"미기성액",	 						Type:"AutoSum", 					SaveName:"PAY_NAMT",				Width:80, 	 Align:"Right", Format:"#,##0", KeyField:"True", CalcLogic:"|SCONT_AMT|-|PRV_PAY_AMT|-|CUR_PAY_AMT|" }
										
			                   		];
			
			
			init_sheet.HeaderMode = {Sort:1};
			IBS_InitSheet(sheet1, init_sheet);
			sheet1.SetDataAutoTrim(0);
// 			sheet1.SetEditable(false);
			sheet1.SetCountPosition(0);
			sheet1.SetCellText(sheet1.LastRow(), "CONT_NM", "합 계");
			sheet1.GetSumFontBold(1);
		
			sheet1.FitColWidth();
		}
	    
	    
	    
	    
	    
	    $.searchList = function()
		{
		    $("#fevent").val("GET_LIST");
		    
			var url = Modular.model.PageContext.CONTEXT_ROOT + "/portal/result/PurResultDetail03_sheet.screen";
			Modular.view.IBSheet7.doSearch(sheet1, url, $("#form1"), 30, "");
			
		};
	    
	    
	    
	    
		$.callCalendar = function(id){
	        
	        var str_value = id;
	        var re = new RegExp("_", "ig");
	        var resultArray = str_value.match(re);
	        
	        if(resultArray.length == 1)
	        {
	            dlgCalendar(id);
	        }
	        else if(resultArray.length == 2)
	        {
	            id = id.substring(0, id.lastIndexOf("_"));
	            dlgCalendar(id);
	        }
	    };
	    
	    $(".numberic").each(function(){
	        $(this).val($(this).val().split(/(?=(?:\d{3})+(?:\.|$))/g).join(',')); 
	    });
	    
	    
	    $("#lic_date_img").click(function(){
	        $.callCalendar($(this).attr("id"));
	    });
	    
	    
	    $("#btn_sheet_add").click(function(){
	        sheet1.DataInsert(-1);
	    });
	    
// 	    $("#btn_sheet_delete").click(function(){
// 	        sheet1.RowDelete(sheet1.LastRow() , 0);
// 	    });
	    
	    
	    $("#btn_save").click(function(){
	        
	        var gubun = $("#p_page_gubun").val();
	        
	        
	        if(confirm("저장 하시겠습니까?"))
            {
	            if(gubun == "info")
	            {
	            	//2016.1.11 반려일때만 금액수정 가능.
	            	if($("#prog_stat_cd").val() != "91"){
		                $("#prog_stat_cd").val("10");
	                }
		            $("#fevent").val("UPDATE_DATA");
		            
		            var url = Modular.model.PageContext.CONTEXT_ROOT + "/portal/result/PurResultDetail03_sheet.screen";
					var result = Modular.view.IBSheet7.doSave(sheet1, url, $("#form1"), false);
	            }
		        else
	            {
		            //$("#prog_stat_cd").val("10");2016.1.11 반려일때만 금액수정 가능. 
		            $("#fevent").val("SAVE_LIST");
		            var url = Modular.model.PageContext.CONTEXT_ROOT + "/portal/result/PurResultDetail03_sheet.screen";
					var result = Modular.view.IBSheet7.doSave(sheet1, url, $("#form1"), false);
	            }
            }
			
	    });
	    
		$("#btn_list").click(function(){
	        
	        //"/portal/result/PurResultIngList.screen"
	        $("#fevent").val("");
	        if($("#p_page_gubun").val() == "target")
            {
	            $("#form1").attr("action", "/portal/result/PurResultTargetList.screen");	            
            }
	        else if($("#p_page_gubun").val() == "info")
            {
	            $("#form1").attr("action", "<%=params.get("p_List") %>");
            }
	        
		    $("#form1").attr("target", "_self");
			$("#form1").attr("method", "post");
			$("#form1").submit();
		    
	    });
		//2016.1.21
	    $("#viewSheet").click(function(){
	    	if ($("#viewSheet").is(":checked") == true)
	    	{
	    		$("#cont_tamt").attr("disabled", false);
	    		$("#prv_pay_amt").attr("disabled", false);
	    		$("#prv_pay_namt").attr("disabled", false);
	    		$("#cur_cont_amt").attr("disabled", false);
	    		$("#cur_pay_amt").attr("disabled", false);
	    		$("#cur_pay_namt").attr("disabled", false);
	    	}
	    	else
	    	{
	    		$("#cont_tamt").attr("disabled", true);
	    		$("#prv_pay_amt").attr("disabled", true);
	    		$("#prv_pay_namt").attr("disabled", true);
	    		$("#cur_cont_amt").attr("disabled", true);
	    		$("#cur_pay_amt").attr("disabled", true);
	    		$("#cur_pay_namt").attr("disabled", true);
	    	}
	    });
		
	    $("#btn_signOk").click(function(){
	    	if(sheet1.LastRow() <= 1 && ($("#viewSheet").is(":checked") == true))
            {
	            alert("복합공종 실적 내용을 입력해 주세요.");
	            $("#isuDiv").attr("tabindex", -1).focus();
	            return;
            } 
 	        
 	        
	    	//2016.1.12 업종필수입력
	    	if ($("#lic_nm").val() == ""){
	    		alert("업종을 입력하십시요.");
	    		$("#lic_nm").focus();
	    		return ;
	    	}
	    	if ($("#work_kind").val() == ""){
	    		alert("공사종류를 입력하십시요.");
	    		$("#work_kind").focus();
	    		return ;
	    	}
	    	
	    	//2016.4.7
 	    	if ($("#viewSheet").is(":checked") == true)
            {
	        	var sumAmt = sheet1.GetSumValue(0 ,"SCONT_AMT");
	        	if( $("#cont_tamt_o").val().replace(/,/gi, "") != sumAmt){   
	 				alert("총 계약금액과 복합공종 계약 합계금액이 일치 하지 않습니다.");
	 				return ;
	 			}
	        	sumAmt = sheet1.GetSumValue(0 ,"CUR_PAY_AMT");
	        	sumAmt = Number(sumAmt) - Number($("#cur_pay_amt_o").val().replace(/,/gi, ""));
	        	if( sumAmt < 0  || sumAmt > 3  ){   
	 				alert("당년도 기성금액과 복합공종 기성 합계금액이 일치 하지 않습니다.");
	 				return ;
	 			}	        	
            }  	        

 	        var chk = "N";
 	      
 	        for (var i = 1; i < sheet1.LastRow(); i++ ){
 	        	if (sheet1.GetCellValue(i, "SUB_SOC_CD") == $("#soc_cd").val()){
	        		chk = "Y";
	        		if (sheet1.GetCellValue(i, "SCONT_AMT") != $("#cont_tamt").val().replace(/,/gi, "") ||  sheet1.GetCellValue(i, "CUR_PAY_AMT") != $("#cur_pay_amt").val().replace(/,/gi, "")  )
	        		{
	        			alert("복합공종의 협회내용과 작성중인 협회금액이 일치하지 않습니다.");
	        			return;
	        		}
	        	}
	        }
 	        
 	        if (chk == "N" && $("#viewSheet").is(":checked") == true) {
 	        	alert("복합공종 내역에 작성중인 협회를 등록하십시요.");
     			return;
 	        }
	    	fMakeItemInfo();
	    });
		
		
		$("#btn_delete").click(function(){
		    
		    var f = document.form1;
		    if(confirm("삭제 하시겠습니까?"))
            {
		    	submitXmlRequest("/portal/result/PurResultDetail01_form.screen", "DELETE_DATA", f, "VALUEOBJECT");
            }
		    
		});
	    
		$("#btn_preview").click(function(){
		    
		    var f = document.form1;
		    
		    if(confirm("저장후 미리보기를 생성 하시겠습니까?"))
            {
	            $("#fevent").val("UPDATE_DATA");
	            $("#pdf").val("PREVIEW_PDF");
	            
	            var url = Modular.model.PageContext.CONTEXT_ROOT + "/portal/result/PurResultDetail03_sheet.screen";
				var result = Modular.view.IBSheet7.doSave(sheet1, url, $("#form1"), false);
		    	
		    	/* $("#fevent").val("PREVIEW_PDF");
		    	submitXmlRequest("/portal/result/PurResultDetail01_form.screen", "PREVIEW_PDF", f); */
            }
		    
		});
		$("#contPopup").click(function(){
	        var win_id = "ResultContPopup";
	        var link = "/portal/result/PurResultContPopup.screen";
		    link += "?pop_win_id="+win_id+"&layerYn=Y";
		    link += "&subContModId="+$("#p_pur_cont_mod_id").val();
			fLayerPop(win_id, link, 550,115, '', '', 'auto');
		});
	});
	
	
	
	
	$(document).ready(function(){
	  
	    $.gridInit(sheet1);
		$.searchList();
		if($("#COMPOSIT_YN").val()=="1"){
			$("#viewSheet").attr("checked",true);
		}else{
			$("#btn_sheet_add_area").css("display", "none");
		}
		
		var prog_stat_cd = "<%=vo.get("prog_stat_cd")%>";
		
		if($("#p_success_gubun").val() == "R")
        {
	        $(':radio[name="p_reson"]').attr("disabled", true);
	        $(':input').attr("readonly", true);
	        $(':input').addClass("bg_gry");
        }
   	    
		//2016.4.7
	 	if(prog_stat_cd == "91" )
        {
            $("#reson_area").css("display", "table-row");
            //2016.1.11 금액관련 모두 수정가능
        }
        else
        {
        	$("#reson_area").css("display", "none");
          //2016.4.7금액관련 모두 수정 불가
            if ($("#viewSheet").is(":checked") == false)
    	    {
            	$("#cont_tamt").attr("disabled", true);
	    		$("#prv_pay_amt").attr("disabled", true);
	    		$("#prv_pay_namt").attr("disabled", true);
	    		$("#cur_cont_amt").attr("disabled", true);
	    		$("#cur_pay_amt").attr("disabled", true);
	    		$("#cur_pay_namt").attr("disabled", true);
    	    }
        }
		
	  	if(prog_stat_cd == "30" )
        {
            $("#viewSheet").css("display", "none");
            $("#btn_sheet_add_area").css("display", "none");
            sheet1.SetEditable(false);
            sheet1.FitColWidth(); 
        }
		
		if($("#p_page_gubun").val() == "info")
	     {
	        if($("#prog_stat_cd").val() == "10" || $("#prog_stat_cd").val() == "00" || $("#prog_stat_cd").val() == "91")
	       	{
	           	$("#signOk").css("display", "inline");
	            $("#btn_preview_area").css("display", "inline");
	       	}
	       	else
	       	{
	            $("#signOk").css("display", "none");
	            $("#btn_preview_area").css("display", "none");
	            $("#btn_save_area").css("display", "none");
	            $("#btn_delete_area").css("display", "none");
	            $("#sheet1_btn").css("display", "none");
	            
	            $("#issue_no").attr("readonly", "true");
	            $("#cont_loc_no").attr("readonly", "true");
	            $("#lic_nm").attr("readonly", "true");
	            $("#work_place").attr("readonly", "true");
	            $("#ord_nm").attr("readonly", "true");
	            $("#ori_cont_nm").attr("readonly", "true");
	            $("#cont_way_nm").attr("readonly", "true");
	            $("#cont_kind").attr("readonly", "true");
	            $("#work_kind").attr("readonly", "true");
	            $("#sub_comp_nm").attr("readonly", "true");
	            $("#sub_comp_no").attr("readonly", "true");
	            $("#numberic").attr("readonly", "true");
	            $("#isu_charge_nm").attr("readonly", "true");
	            $("#isu_req_hp1").attr("readonly", "true");
	            $("#isu_req_hp2").attr("readonly", "true");
	            $("#isu_req_hp3").attr("readonly", "true");
	            
	            
	       	}
	     }
		    else
	     {
		        $("#signOk").css("display", "none");
		        $("#btn_preview_area").css("display", "none");
		        $("#btn_delete_area").css("display", "none");
	     }
		
		$("#viewSheet").click(function() {
			viewSheet();
		});
		
	}) ;
	
	
	function viewSheet(){
		if($("#viewSheet").is(":checked") == true){
			sheet1.SetEditable(true);
			$("#btn_sheet_add_area").css("display", "inline");
			$("#COMPOSIT_YN").val("1");
		}else{
			if(sheet1.RowCount()!="0"){		//row가 남아있을때 확인
				if(confirm("작성된 내용을 삭제 하시겠습니까?")){
					sheet1.CheckAll(0,1);
					sheet1.SetEditable(false);
					$("#btn_sheet_add_area").css("display", "none");
					$("#COMPOSIT_YN").val("0");
				}
			}else{							//row 없을때
				sheet1.SetEditable(false);
				$("#btn_sheet_add_area").css("display", "none");
				$("#COMPOSIT_YN").val("0");
			}
		}
	}
	
	
	function sheet1_OnSaveEnd(code, msg)
	{
		var event = $("#fevent").val();
		var f = document.form1;
		
		document.form1.isSubmit = false;
		
		if(code >= "0")
		{
		    if(event == "SAVE_LIST")
	        {
		        alert("저장이 완료되었습니다.");
			    location.href="/portal/result/PurResultIngList.screen";
	        }
		    else if(event == "UPDATE_ISSUE")
	        {
		        alert("발급요청을 하였습니다.");
		        location.href="/portal/result/PurResultIngList.screen";
	        }
		    else if(event == "SIGN_OK")
	        {
		    	alert("서명 되었습니다.");
				$("#fevent").val("GET_DETAIL_03");
				
				$("#form1").attr("action", "/portal/result/PurResultDetail03.screen");
				$("#form1").submit();
	        }
		    else if($("#pdf").val()=="PREVIEW_PDF")
		    {
		    	var reportInfo = new ReportInfo();
			    
	            reportInfo.title = "한국소방시설협회 실적증명";
	            reportInfo.reportName = "/report/mrd/buyer/supplier/pur_fire_application.mrd";
	            reportInfo.set("<%=vo.get("corp_id")%>");    			// $1
	            reportInfo.set("<%=vo.get("pur_cont_mod_id")%>");    	// $2
	            reportInfo.set("<%=vo.get("acmp_yyyy")%>");    			// $3
	            reportInfo.set("<%=vo.get("soc_cd")%>");    			// $4
	            
		        reportInfo.width = 1000;                         	// Default: 1024
		        reportInfo.height = 700;                         	// Default: 768
				reportInfo.showPopup();
				$("#pdf").val("");
		    }
		    else
	        {
		        alert("수정이 완료되었습니다.");
		        
  				$("#fevent").val("GET_DETAIL_03");
				
				$("#form1").attr("action", "/portal/result/PurResultDetail03.screen");
				$("#form1").submit();
	        }
		}
	}
	
	
	
	
	function doResult(resultObj) 
	{
	    try 
		{
		    document.form1.isSubmit = false;
		    
		    if( resultObj.getRequestEvent() == "UPDATE_ISSUE") 
			{
		        if( resultObj.getSuccess() ) 
				{
					alert("등록 되었습니다.");
					location.href="/portal/result/PurResultIngList.screen";
				}
				else 
				{
	// 				dlgErrorMsg(resultObj.getMessage);
					alert(resultObj.getValueObject().get("errMsg"));
				}
			}
		    else if( resultObj.getRequestEvent() == "DELETE_DATA") 
			{
		        if( resultObj.getSuccess() ) 
				{
					alert("삭제 되었습니다.");
					location.href="/portal/result/PurResultTargetList.screen";
				}
				else 
				{
	// 				dlgErrorMsg(resultObj.getMessage);
					alert(resultObj.getValueObject().get("errMsg"));
				}
			}
			else if( resultObj.getRequestEvent() == "PREVIEW_PDF") 
			{
		        if( resultObj.getSuccess() ) 
				{
		        	alert("미리보기가 생성 되었습니다.");
		        	var url="/common/file/FileDownloadServlet?mode=fpDown&filePath=/result/<%=vo.get("pur_cont_mod_id")%>/<%=vo.get("acmp_yyyy")%>&fileName=preview_<%=vo.get("corp_id")%>.pdf&fileRealName=preview_<%=vo.get("corp_id")%>.pdf";
			  		window.open(url, "_blank");
				}
				else 
				{
	// 				dlgErrorMsg(resultObj.getMessage);
					alert(resultObj.getValueObject().get("errMsg"));
				}
			}
		}
		catch(errorObject) {
			showErrorDlg("doResult()", errorObject);
		}
	}

	
	function fMakeItemInfo(){
		
		var sColumDelimiter = "┃";
		var sRowDelimiter		= "↕";
		var sSumDelimiter		= "╂";
		var sEncDelimiter		= "⇔";
		var isNull	= "NULL";
//해시
		var	sContHash				=	"";
		var	sTemplate				=	"01";			
		var	sMainVendcd				=	"<%=vo.get("isu_vendcd") %>";  
		//var	sMainVendcd				=	"1234567890";	//	원사업자번호
		var issue_no ="<%=vo.get("issue_no") %>";
		var lic_nm ="<%=vo.get("lic_nm") %>";
		var cont_loc_no ="<%=vo.get("cont_loc_no") %>";
		var work_place ="<%=vo.get("work_place") %>";
		var ord_nm ="<%=vo.get("ord_nm") %>";
		var ori_cont_nm ="<%=vo.get("ori_cont_nm") %>";
		var cont_way_nm ="<%=vo.get("cont_way_nm") %>";
		var cont_kind ="<%=vo.get("cont_kind") %>";
		var work_kind ="<%=vo.get("work_kind") %>";
		var prv_pay_amt ="<%=vo.get("prv_pay_amt") %>";
		var prv_pay_namt ="<%=vo.get("prv_pay_namt") %>";
		var cur_cont_amt ="<%=vo.get("cur_cont_amt") %>";
		var cur_pay_amt ="<%=vo.get("cur_pay_amt") %>";
		var cur_pay_namt ="<%=vo.get("cur_pay_namt") %>";
		var sub_comp_nm ="<%=vo.get("sub_comp_nm") %>";
		var sub_comp_no ="<%=vo.get("sub_comp_no") %>";
		var sub_amt ="<%=vo.get("sub_amt") %>";
		
		sContHash=issue_no		+sColumDelimiter
				+lic_nm		+sColumDelimiter
				+cont_loc_no		+sColumDelimiter
				+work_place		+sColumDelimiter
				+ord_nm		+sColumDelimiter
				+ori_cont_nm		+sColumDelimiter
				+cont_way_nm		+sColumDelimiter
				+cont_kind		+sColumDelimiter
				+work_kind		+sColumDelimiter
				+prv_pay_amt		+sColumDelimiter
				+prv_pay_namt		+sColumDelimiter
				+cur_cont_amt	+sColumDelimiter
				+cur_pay_amt	+sColumDelimiter
				+cur_pay_namt	+sColumDelimiter
				+sub_comp_nm	+sColumDelimiter
				+sub_comp_no	+sColumDelimiter
				+sub_amt			+sRowDelimiter;
				
		var GrowCount = sheet1.LastRow();
	
		for(var	i=1; i < 	GrowCount+1; i++)
		{
			
			var	cont_nm			=	"";							
			var	cont_amt						=	"";			
			var	cont_sdate				=	"";					
			var	cont_edate		=	"";							
			var	prv_pay_amt			=	"";						
			var	cur_pay_amt						=	"";			
			var	scont_amt						=	"";			
			var	pay_namt						=	"";			

			
			
			cont_nm = sheet1.GetCellValue(i,"CONT_NM");
			if(cont_nm.length > 0){
				cont_amt = sheet1.GetCellValue(i,"CONT_AMT");
				if(isEmptyVal(cont_amt))
					cont_amt = isNull;
				cont_sdate = sheet1.GetCellValue(i,"CONT_SDATE");
				if(isEmptyVal(cont_sdate))
					cont_sdate = isNull;
				cont_edate = sheet1.GetCellValue(i,"CONT_EDATE");
				if(isEmptyVal(cont_edate))
					cont_edate = isNull;
				prv_pay_amt = sheet1.GetCellValue(i,"PRV_PAY_AMT");
				if(isEmptyVal(prv_pay_amt))
					prv_pay_amt = isNull;
				cur_pay_amt = sheet1.GetCellValue(i,"CUR_PAY_AMT");
				if(isEmptyVal(cur_pay_amt))
					cur_pay_amt = isNull;
				scont_amt = sheet1.GetCellValue(i,"SCONT_AMT");
				if(isEmptyVal(scont_amt))
					scont_amt = isNull;
				pay_namt = sheet1.GetCellValue(i,"PAY_NAMT");
				if(isEmptyVal(pay_namt))
					pay_namt = isNull;
				
				sContHash	=	sContHash
									+	sTemplate	+	sColumDelimiter           
									+	sMainVendcd	+	sColumDelimiter           
									+	cont_amt	+	sColumDelimiter           
									+	cont_sdate	+	sColumDelimiter           
									+	cont_edate	+	sColumDelimiter           
									+	prv_pay_amt	+	sColumDelimiter           
									+	cur_pay_amt +	sColumDelimiter           
									+  	scont_amt 	+	sColumDelimiter               
									+	pay_namt	+	sRowDelimiter
			} 
		}
		 $("#CONT_HASH").val(sContHash);

		 if(confirm("서명 하시겠습니까?")){
			 SignData();	 
		 }
	}
	
	function isEmptyVal( value ) {
		if(value.length == 0){
			return true;
		}
		if( value == "" ) {
			return true;
		}
		return false;
	}

	
//-->
</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="" /> <INPUT
		type="hidden" name="pdf" id="pdf" value="" /> <input
		type="hidden" name="p_page_gubun" id="p_page_gubun"
		value="<%=params.get("p_page_gubun")%>" />
		<input type="hidden" name="p_List" id="p_List" value="<%=params.get("p_List") %>" />
		 <input type="hidden"
		name="p_pur_cont_mod_id" id="p_pur_cont_mod_id"
		value="<%=vo.get("pur_cont_mod_id")%>" /> <input type="hidden"
		name="p_acmp_yyyy" id="p_acmp_yyyy" value="<%=vo.get("acmp_yyyy")%>" />
	<input type="hidden" name="p_corp_id" id="p_corp_id"
		value="<%=vo.get("corp_id")%>" /> <input type="hidden"
		name="p_soc_cd" id="p_soc_cd" value="<%=params.get("p_soc_cd")%>" />

	<input type="hidden" name="pur_cont_mod_id" id="pur_cont_mod_id" value="<%=vo.get("pur_cont_mod_id")%>" /> 
	<input type="hidden" name="acmp_yyyy" id="acmp_yyyy" value="<%=vo.get("acmp_yyyy")%>" />
	<input type="hidden" name="corp_id" id="corp_id" value="<%=vo.get("corp_id")%>" /> 
	<input type="hidden" name="soc_cd" id="soc_cd" value="<%=params.get("p_soc_cd")%>" /> 
	<input type="hidden" name="dept_cd" id="dept_cd" 	value="<%=vo.get("dept_cd")%>" /> 
	<input type="hidden" name="dept_nm" id="dept_nm" value="<%=vo.get("dept_name")%>" /> 
	<input type="hidden" name="isu_vendcd" id="isu_vendcd" value="<%=vo.get("isu_vendcd")%>" /> 
	<input type="hidden" name="con_amt" id="con_amt" value="<%=vo.get("con_amt")%>" /> 
	<input type="hidden" name="prog_stat_cd" id="prog_stat_cd" value="<%=vo.get("prog_stat_cd")%>" /> 
	<input type="hidden" name="p_success_gubun" id="p_success_gubun" value="<%=params.get("p_success_gubun")%>" /> 
	<input type="hidden" name="p_yyyy" id="p_yyyy" value="<%=params.get("p_yyyy")%>" /> 
	<input type="hidden" name="p_dept_nm" id="p_dept_nm"	value="<%=params.get("p_dept_nm")%>" /> 
	<input type="hidden" name="p_cont_nm" id="p_cont_nm" value="<%=params.get("p_cont_nm")%>" />
	<input type="hidden" name="COMPOSIT_YN" id="COMPOSIT_YN" value="<%=vo.get("COMPOSIT_YN")%>" />

	<input type="hidden" name="PRV_PAY_AMT_O" id="PRV_PAY_AMT_O" value= "<%=vo.get("PRV_PAY_AMT_O") %>" />
	<input type="hidden" name="CUR_PAY_NAMT_O" id="CUR_PAY_NAMT_O" value= "<%=vo.get("CUR_PAY_NAMT_O") %>" />
	<!--서명 데이터 정보  START-->
	<INPUT type='hidden' name="CONT_HASH" value=""> <INPUT
		type='hidden' name="sItemInfo" value=""> <INPUT type='hidden'
		name="CONT_SIGNDATA" value=""> <INPUT type='hidden'
		name="CONT_SIGNDN" value=""> <INPUT type='hidden'
		name="signeddata" value=""> <INPUT type='hidden'
		name="signEnddt" value="">

	<div align="left" id="title" style="float: left;">
		<ul>
			<li>실적증명 상세(<%=vo.get("PROG_STAT_NM").equals("") ? "작성대상" : vo
					.get("PROG_STAT_NM")%>)
			</li>
		</ul>
	</div>

	<div style="float: right; margin-top: 16px;">
		<span class="btnSearch center"><a href="javascript:void(0);" id="btn_list">목록</a></span> 
		<!--<span class="btnSearch center" id="btn_preview_area"><a href="javascript:void(0);" id="btn_preview">미리보기</a></span> -->
		<span class="btnSearch center" id="btn_save_area"><a href="javascript:void(0);" id="btn_save">저장</a></span>
		<span class="btnSearch center" id="signOk"><a href="javascript:void(0);" id="btn_signOk">서명</a></span> 
		<span class="btnSearch center" id="btn_delete_area"><a href="javascript:void(0);" id="btn_delete">삭제</a></span>
	</div>

	<!-- 기성실적증명서 정보 -->
	<div style="float: left;" class="application-info  magT10">
		<div class="application-sub-title">
			<span class="title">기성실적증명서 정보</span>
		</div>
		<div class="application-location"></div>
	</div>

	<table border="0" cellspacing="0" cellpadding="0" width="100%"
		height="100%" class=form-table>
		<colgroup>
			<col width="15%" />
			<col width="85%" />
		</colgroup>
		<!-- 검색조건 영역, 테이터 영역 구분 여백 : 시작 -->
		<tr>
			<th style="text-align: left;">발 급 협 회</th>
			<td>한국소방시설협회</td>
		</tr>
		
		<tr id="reson_area">
			<th style="text-align: left;">반려사유</th>
			<td><%=vo.get("return_reson").replace("\n", "<br/>")%>
			</td>
		</tr>
	</table>

	<!-- 신청인 -->
	<div style="float: left;" class="application-info  magT10">
		<div class="application-sub-title">
			<span class="title">신청인</span>
		</div>
		<div class="application-location"></div>
	</div>



	<table border="0" cellspacing="0" cellpadding="0" width="100%"
		height="100%" class=form-table>
		<colgroup>
			<col width="15%" />
			<col width="35%" />
			<col width="15%" />
			<col width="35%" />
		</colgroup>
		<!-- 검색조건 영역, 테이터 영역 구분 여백 : 시작 -->
		<tr>
			<th style="text-align: left;">상 호</th>
			<td colspan="3"><input type="text" name="isu_vendnm"
				id="isu_vendnm" value="<%=vo.get("ISU_VENDNM")%>"
				class="bg_gry input_blank" readonly="readonly" /></td>
		</tr>
		<tr>
			<th style="text-align: left;">대 표 자</th>
			<td><input type="text" name="isu_pres_nm" id="isu_pres_nm"
				value="<%=vo.get("isu_pres_nm")%>" class="bg_gry input_blank"
				readonly="readonly" /></td>
			<th style="text-align: left;">전화번호</th>
			<td><input type="text" name="isu_phone" id="isu_phone"
				value="<%=vo.get("isu_phone")%>" class="bg_gry input_blank"
				readonly="readonly" /></td>
		</tr>
		<tr>
			<th style="text-align: left;">영업소 소재지</th>
			<td colspan="3"><input type="text" name="isu_addr" id="isu_addr"
				value="<%=vo.get("ISU_ADDR")%>"  style="width: 100%;"
				  /></td>
		</tr>
	</table>


	<!-- 소방시설공사 내용 -->
	<div style="float: left;" class="application-info  magT10">
		<div class="application-sub-title">
			<span class="title">소방시설공사 내용</span>
			<img alt="팝업" id="contPopup" name="contPopup" src="/img/buyer/button/bt_search_right.gif" style="vertical-align: middle; cursor: pointer;"/>
		</div>
		<div class="application-location"></div>
	</div>


	<table border="0" cellspacing="0" cellpadding="0" width="100%"
		height="100%" class=form-table>
		<colgroup>
			<col width="15%" />
			<col width="35%" />
			<col width="15%" />
			<col width="35%" />
		</colgroup>
		<!-- 검색조건 영역, 테이터 영역 구분 여백 : 시작 -->
		<tr>
			<th style="text-align: left;">공사명</th>
			<td><input type="text" name="cont_nm" id="cont_nm"
				value="<%=vo.get("cont_nm")%>"  style="width: 100%;"
				  /></td>
			<th style="text-align: left;">업종</th>
			<td><input type="text" name="lic_nm" id="lic_nm"
				value="<%=vo.get("lic_nm")%>" style="width: 100%;" /></td>
		</tr>

		<tr>
			<th style="text-align: left;">공사지역</th>
			<td><input type="text" name="cont_loc_no" id="cont_loc_no"
				value="<%=vo.get("cont_loc_no")%>" style="width: 100%;" /></td>
			<th style="text-align: left;">공사현장</th>
			<td><input type="text" name="work_place" id="work_place"
				value="<%=vo.get("work_place")%>" style="width: 100%;" /></td>
		</tr>

		<tr>
			<th style="text-align: left;">발주자</th>
			<td><input type="text" name="ord_nm" id="ord_nm"
				value="<%=vo.get("ord_nm")%>" style="width: 100%;" /></td>
			<th style="text-align: left;">원도급자</th>
			<td><input type="text" name="ori_cont_nm" id="ori_cont_nm" readonly="readonly" 
				value="SGC이앤씨(주)" style="width: 100%;" /></td><%-- <%=vo.get("ori_cont_nm")%> --%>
		</tr>

		<tr>
			<th style="text-align: left;">계약연월</th>
			<td><input type="text" name="cont_cdate" id="cont_cdate"
				value="<%=vo.get("cont_cdate")%>" class="bg_gry input_blank"
				readonly="readonly" style="width: 80px;" /></td>
			<th style="text-align: left;">착공연월</th>
			<td><input type="text" name="cont_sdate" id="cont_sdate"
				value="<%=vo.get("cont_sdate")%>" class="bg_gry input_blank"
				readonly="readonly" style="width: 80px;" /></td>
		</tr>

		<tr>
			<th style="text-align: left;">준공연월</th>
			<td><input type="text" name="cont_edate" id="cont_edate"
				value="<%=vo.get("cont_edate")%>" class="bg_gry input_blank"
				readonly="readonly" style="width: 80px;" /></td>
			<th style="text-align: left;">계약방법</th>
			<td><LABEL for="bid_1"><INPUT id="bid_1" type="radio" name="CONT_WAY_NM" value="1" desc="입찰방식" <%=vo.get("CONT_WAY_NM").equals("1") ? "checked=\"checked\"" : ""%>>지명경쟁</LABEL>
	            <LABEL for="bid_2"><INPUT id="bid_2" type="radio" name="CONT_WAY_NM" value="2" desc="입찰방식" <%=vo.get("CONT_WAY_NM").equals("2") ? "checked=\"checked\"" : ""%>>수의계약</LABEL> 
	        </td>
		</tr>

		<tr>
			<th style="text-align: left;">도급종류</th>
			<td><input type="text" name="cont_kind" id="cont_kind"
				value="<%=vo.get("cont_kind")%>" /></td>
			<th style="text-align: left;">공사종류</th>
			<td><input type="text" name="work_kind" id="work_kind"
				value="<%=vo.get("work_kind")%>" /></td>
		</tr>

	</table>


	<!-- 소방시설공사 실적금액(부가세 포함) -->
	<div style="float: left;" class="application-info  magT10">
		<div class="application-sub-title">
			<span class="title">소방시설공사 실적금액(부가세 포함)</span>
		</div>
		<div class="application-location"></div>
	</div>

	<table border="0" cellspacing="0" cellpadding="0" width="100%"
		height="100%" class=form-table>
		<colgroup>
			<col width="15%" />
			<col width="35%" />
			<col width="15%" />
			<col width="35%" />
		</colgroup>
		<!-- 검색조건 영역, 테이터 영역 구분 여백 : 시작 -->
		<tr>
			<th style="text-align: left;">계약금액(총계약금액)</th>
			<td><input type="text" name="cont_tamt" id="cont_tamt"  value="<%=vo.get("cont_tamt")%>" style="text-align: right; width: 200px;" numberOnly="true"  class="numberic" /> 천원
			(<input type="text" name="cont_tamt_o" id="cont_tamt_o" value="<%=vo.get("cont_tamt_O") %>"  style="text-align: right; width: 70px;" class="numberic bg_gry input_blank"  readonly="readonly" /> ) 
			</td>
			<th style="text-align: left;">전년까지의 누계기성액</th>
			<td><input type="text" name="prv_pay_amt" id="prv_pay_amt" value="<%=vo.get("prv_pay_amt")%>" style="text-align: right; width: 200px;" numberOnly="true"  class="numberic" maxlength="20" /> 천원</td>
		</tr>

		<tr>
			<th style="text-align: left;">전년까지의 미기성액</th>
			<td><input type="text" name="prv_pay_namt" id="prv_pay_namt" value="<%=vo.get("prv_pay_namt")%>"	style="text-align: right; width: 200px;" numberOnly="true" class="numberic" maxlength="20" /> 천원</td>
			<th style="text-align: left;">해당연도 계약액</th>
			<td><input type="text" name="cur_cont_amt" id="cur_cont_amt" value="<%=vo.get("cur_cont_amt")%>"	style="text-align: right; width: 200px;" numberOnly="true" class="numberic" maxlength="20" /> 천원</td>
		</tr>

		<tr>
			<th style="text-align: left;">해당연도 기성액(총기성액)</th>
			<td><input type="text" name="cur_pay_amt" id="cur_pay_amt"	value="<%=vo.get("cur_pay_amt")%>" style="text-align: right; width: 200px;" numberOnly="true"  class="numberic" maxlength="20" /> 천원
			(<input type="text" name="cur_pay_amt_o" id="cur_pay_amt_o" value="<%=vo.get("cur_pay_amt_O") %>"  style="text-align: right; width: 70px;" class="numberic bg_gry input_blank"  readonly="readonly" /> ) </td>
			<th style="text-align: left;">해당연도 미기성액</th>
			<td><input type="text" name="cur_pay_namt" id="cur_pay_namt"
				value="<%=vo.get("cur_pay_namt")%>"
				style="text-align: right; width: 200px;" numberOnly="true"   
				class="numberic" maxlength="20" /> 천원</td>
		</tr>

		<tr>
			<th style="text-align: left;">하도급 업체명</th>
			<td><input type="text" name="sub_comp_nm" id="sub_comp_nm"
				value="<%=vo.get("sub_comp_nm")%>" /></td>
			<th style="text-align: left;">하도급 면허번호</th>
			<td><input type="text" name="sub_comp_no" id="sub_comp_no"
				value="<%=vo.get("sub_comp_no")%>" /></td>
		</tr>

		<tr>
			<th style="text-align: left;">하도급 금액</th>
			<td colspan="3"><input type="text" name="sub_amt" id="sub_amt"
				value="<%=vo.get("sub_amt")%>" style="text-align: right;"
				numberOnly="true" class="numberic" maxlength="20" /></td>
		</tr>
	</table>



	<!-- 복합공종-->
	<div style="float: left;" class="application-info  magT10">
		<div class="application-sub-title">
			<span class="title">복합공종(타공종 포함) 실적 내용 (단위:천원, 부가세 포함) <input
				type="checkbox" id="viewSheet"></span>
		</div>
		<div class="application-location"></div>
	</div>
	<div id="sheetDiv">
		<div style="float: right; margin-top: -23px; margin-bottom: 5px;"
			id="sheet1_btn">
			<span class="btnSearch center" id="btn_sheet_add_area"><a
				href="javascript:void(0);" id="btn_sheet_add">추가</a></span>
			<!-- 	<span class="btnSearch center"><a href="javascript:void(0);" id="btn_sheet_delete">삭제</a></span> -->
		</div>


		<!-- 시트 -->
		<div
			style="width: 100%; height: 150px; margin-top: 5px; margin-bottom: 80px;">
			<!-- 데이터 영역 : 시작 -->
			<!-- ibsheet7 그리드 생성 -->
			<script>createIBSheet("sheet1","100%", "150px;");</script>
			<!-- 데이터 영역 : 종료 -->
		</div>
	</div>

	<!-- 요청자 정보 -->
	<div style="float: left;" class="application-info  magT10">
		<div class="application-sub-title">
			<span class="title">발급요청자 정보</span>
		</div>
		<div class="application-location"></div>
	</div>

	<table border="0" cellspacing="0" cellpadding="0" width="100%"
		height="100%" class=form-table>
		<colgroup>
			<col width="15%" />
			<col width="35%" />
			<col width="15%" />
			<col width="35%" />
		</colgroup>
		<!-- 검색조건 영역, 테이터 영역 구분 여백 : 시작 -->
		<tr>
			<th style="text-align: left;">담당자명</th>
			<td><input type="text" name="isu_charge_nm" id="isu_charge_nm"
				value="<%=vo.get("isu_charge_nm").equals("") ? user
					.get("user_name") : vo.get("isu_charge_nm")%>" />
			</td>
			<th style="text-align: left;">휴대전화</th>
			<td><input type="text" name="isu_req_hp1" id="isu_req_hp1"
				value="<%=vo.get("isu_req_hp1").equals("") ? user.get("hp1") : vo
					.get("isu_req_hp1")%>"
				style="width: 80px;" maxlength="3" number="true" /> - <input
				type="text" name="isu_req_hp2" id="isu_req_hp2"
				value="<%=vo.get("isu_req_hp2").equals("") ? user.get("hp2") : vo
					.get("isu_req_hp2")%>"
				style="width: 120px;" maxlength="4" number="true" /> - <input
				type="text" name="isu_req_hp3" id="isu_req_hp3"
				value="<%=vo.get("isu_req_hp3").equals("") ? user.get("hp3") : vo
					.get("isu_req_hp3")%>"
				style="width: 120px;" maxlength="4" number="true" /></td>
		</tr>
	</table>


	<%
		if (vo.get("prog_stat_cd").equals("30")) {
	%>
	<div id="file_area" style="width: 100%;">
		<!-- 첨부파일 -->
		<div style="float: left;" class="application-info  magT10">
			<div class="application-sub-title">
				<span class="title">첨부파일</span>
			</div>
			<div class="application-location"></div>
		</div>

		<table border="0" cellspacing="0" cellpadding="0" width="100%"
			height="100%" class=form-table>
			<colgroup>
				<col width="15%" />
				<col width="35%" />
				<col width="15%" />
				<col width="35%" />
			</colgroup>
			<!-- 검색조건 영역, 테이터 영역 구분 여백 : 시작 -->
			<tr>
				<th style="text-align: left;">첨부파일</th>
				<td colspan="3">
					<div id="auto_attach_file_view" class="attach_file_view">
						<ul>
							<%
								for (int i = 0; i < fileRowSet.size(); i++) {
							%>
							<li><a
								href="/common/file/FileDownloadServlet?mode=fpDown&filePath=<%=fileRowSet.getRow(i).get("FILE_PATH")%>&fileName=<%=URLEncoder.encode(
							fileRowSet.getRow(i).get("FILE_NAME"), "UTF-8")%>&fileRealName=<%=fileRowSet.getRow(i).get("REAL_FILE_NAME")%>"><%=i + 1%>
									: <%=fileRowSet.getRow(i).get("FILE_NAME")%> (<%=fileRowSet.getRow(i).get("FILE_SIZE").trim()%>)</a>
							</li>
							<%
								}
							%>
						</ul>
					</div>
				</td>
			</tr>
		</table>

	</div>
	<%
		}
	%>


</form>





<!-- ------------------서명 요청 처리 로직-------- -->
<SCRIPT LANGUAGE="JavaScript">

function SignData()
{
	var VendorCd = "<%=vo.get("isu_vendcd")%>"; 
// 	VendorCd = '2234567890';
	var sOrgnData = $("#CONT_HASH").val();
	 
	unisign.SignDataNVerifyVID( sOrgnData, null, VendorCd, function( resultObject ) {
			if( !resultObject || resultObject.resultCode != 0 ){
// 				alert( resultObject.resultMessage + "\n오류코드 : " + resultObject.resultCode );

				if( resultObject.resultCode == '14208'){
					alert("주민번호/사업자번호를 확인할 수 없는 인증서입니다.");
				} else if( resultObject.resultCode == '999'){
					alert("사용자 DN 선택이 취소 되었습니다.");
				} else {
					alert( resultObject.resultMessage);
				}
				
				return;
			}
			
			var signeddata = resultObject.signedData;
			var userdn = resultObject.certAttrs.subjectName;
			
// 			alert(signeddata);//인증서 이름
// 			alert(userdn);//인증서 이름
			
			$("#CONT_SIGNDATA").val(signeddata);
			$("#CONT_SIGNDN").val(userdn);
			
			$("#fevent").val("SIGN_OK");
			
            var url = Modular.model.PageContext.CONTEXT_ROOT + "/portal/result/PurResultDetail03_sheet.screen";
			var result = Modular.view.IBSheet7.doSave(sheet1, url, $("#form1"), false);	
		}
	);

}

</SCRIPT>


<div id="CONTROL_LAYER"
	style="position: absolute; z-index: 10; visibility: hidden;">

	<script>
</script>
</div>

<!-- 전자인증 모듈 설정 //-->
<link rel="stylesheet" type="text/css" href="/CrossCert/CC_WSTD_home/unisignweb/rsrc/css/certcommon.css?v=1" />
<script type="text/javascript" src="/CrossCert/CC_WSTD_home/unisignweb/js/unisignwebclient.js?v=1"></script>
<script type="text/javascript" src="/CrossCert/UniSignWeb_Multi_Init_Nim.js?v=1"></script>
<!-- 전자인증 모듈 설정 //-->
