<%--
  - FileName   : SuppDeptRequest.jsp
  - Author(s)  : mklee	
  - Date       : 2016-12-21	
  --%>
  

<%@ 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.udapsoft.common.code.*" %>
<%@ page import="kr.co.hsnc.common.util.*"%>
<%@ page import="kr.co.hsnc.common.sql.*" %>
<%@ page import="kr.co.hsnc.common.config.WAFConfig" %>
<%@ include file="/jsp/work/taglib.jsp" %>
<%@ page import="kr.co.hsnc.common.util.Formatter"%>
<%@ page import="java.net.URLEncoder"%>
<%@ page import="kr.co.udapsoft.ebid.buyer.common.file.FileManager"%>

<jsp:useBean id="ctx" class="com.udapsoft.waf.system.context.SessionContext" scope="session" />

 
<%
    ctx.init(request, response);
    HandlerStorage storage = ctx.getHandlerStorage();
    ValueObject params = storage.getParams();
    ValueObject user = storage.getUser();
    String event = storage.getEvent();
    
    ValueObject vo = storage.getValueObject("SuppJoinRequest");
    RowSet getFileListRowSet = storage.getRowSet("getFileListRowSet");
    
    String status = "";
    status = params.get("status");
    
	String job_gubun = "외주";
    
    java.util.Calendar curDate = java.util.Calendar.getInstance();
    curDate.add ( curDate.YEAR, 0 ); 
	java.text.SimpleDateFormat fmtDay = new java.text.SimpleDateFormat("yyyy");
	String nyear = fmtDay.format(curDate.getTime()); // 오늘 
	
	String gwurl	=	"http://gw.sgcenc.co.kr/";
	
	if (params.get("corp_status").isEmpty()){
		params.set("corp_status","A");
	}
%>

<SCRIPT language="JavaScript">
	$(function(){
		
		var event = "<%=event%>";
	    var status =  "<%=vo.get("STATUS_CODE")%>";  
 
	    var f = document.form1;
	    getFileListForTextarea();
	    
	    if(event == "")  //신규
		{
		    $("#btn_confim_area").css("display", "none");
		    $("#btn_delete_area").css("display", "none");
            $("#REJECT_REASON").attr("readonly", true);
            $("#btn_approval").css("display", "none");
            $("#btn_reject").css("display", "none");
            document.getElementById('CREDIT_VALUE1').innerHTML =  "신용평가등급";
            document.getElementById('LICENCE_YN_TEXT').innerHTML =  "미보유";
		}
	    else if(event == "GET_DETAIL")
		{
	        $("#corp_reg_no").attr("readonly", true);
	        $("#corp_reg_no").css("background-color", "#f0f0f0");
	        
	         if ("<%= vo.get("liquid_rate")%>" < 100) {
				document.getElementById('liquid_rate1').innerHTML = "<font color='red'>" + "<%= vo.get("liquid_rate")%>" + "</font>";  
			}else{
				document.getElementById('liquid_rate1').innerHTML =  "<%= vo.get("liquid_rate")%>";
			}
	        if ("<%= vo.get("debt_rate")%>" > 250) {
				document.getElementById('debt_rate1').innerHTML = "<font color='red'>" + "<%= vo.get("debt_rate")%>" + "</font>";  
			}else{
				document.getElementById('debt_rate1').innerHTML =  "<%= vo.get("debt_rate")%>";
			}
	        if (Number("<%= nyear%>") - Number(<%= vo.get("syear")%>) <= 2 ) {
				document.getElementById('syear1').innerHTML = "영업기간 2년미만";  
			}else{
				document.getElementById('syear1').innerHTML =  "";
			}
	        if ( "<%= vo.get("LICENCE_YN") %>" == "N" ) {
				document.getElementById('LICENCE_YN_TEXT').innerHTML = "<font color='red'><b>" +  "미보유" + "</b></font>";    
			}else{
				document.getElementById('LICENCE_YN_TEXT').innerHTML =  "미보유";
			} 
	        if ( ("<%= vo.get("CREDIT_VALUE1")  %>" > "C") || ("<%= vo.get("CASH_GRADE1")  %>" > "C") ) { 
				document.getElementById('CREDIT_VALUE1').innerHTML = "<font color='red'>" +  "신용평가등급" + "</font>";    
			}else{
				document.getElementById('CREDIT_VALUE1').innerHTML =  "신용평가등급";
			}
	        
	        if(status == "AA" || status == "BB") //수정가능상태 
            {
	        	/*작성자만 수정가능*/
	        	<% if ( vo.get("cre_by").equals(user.get("acct_id")) ) {%>
 	            $("#btn_confim").css("display", "inline");
 	            $("#btn_save").css("display", "inline");
	            $("#btn_delete_area").css("display", "inline");
	            $("#REJECT_REASON").attr("readonly", true);
	            <%}else{%>
	            $("#btn_confim").css("display", "none");
 	            $("#btn_save").css("display", "none");
	            $("#btn_delete_area").css("display", "none");
	            $("#REJECT_REASON").attr("readonly", true);
	            <%}%>
	            
            }
	        else  //00, BB, 03 
            {
	        	$("#btn_confim").css("display", "none");
 	            $("#btn_save").css("display", "none");
	            $("#btn_delete_area").css("display", "none");
            }
	        
	        //외주담당자
	        if ( "<%= user.get("RIGHT_NAME")%>" == "OUTSIDE" && status == "00" ) { 
	            $("#btn_approval").css("display", "inline");
	            $("#btn_reject").css("display", "inline");
	        }else
	        {
	            $("#btn_approval").css("display", "none");
                $("#btn_reject").css("display", "none");
	        }
	        setCreditValue();
		}
	    	     
	    //숫자만 입력받기.
		//$(document).on("keyup", "input:text[numberOnly]", function() {$(this).val( $(this).val().replace(/[^0-9]/gi,"") );});
	    
	    //부채비율
		$("#debt_amt").keyup(function(){debt_rate();});
		$("#capital_amt").keyup(function(){debt_rate();});
		//유동비율
	    $("#liquid_asset").keyup(function(){liquid_rate();});
		$("#liquid_debt").keyup(function(){liquid_rate();});
		$("#syear").keyup(function(){syear();});
		$("#LICENCE_YN1").click(function(){LICENCE_YN();});
		$("#LICENCE_YN2").click(function(){LICENCE_YN();});
		$("#LICENCE_YN3").click(function(){LICENCE_YN();});
		$("#CREDIT_VALUE").click(function(){CREDIT_VALUE();});
		$("#CASH_GRADE").click(function(){CREDIT_VALUE();});
		
		$("#btn_list").click(function(){
			$("#fevent").val("");
		    $("#form1").attr("action", "/supplier/outside/SuppDeptRequestList.screen");
			$("#form1").attr("target", "_self");
			$("#form1").attr("method", "post");
			$("#form1").submit();
		});
		
		$("#btn_approval").click(function(){
		    if(confirm("승인 하시겠습니까?"))
            {
	            $("#p_status").val("03");
		        submitXmlRequest("/supplier/outside/SuppDeptRequest_form.screen", "DATA_APP", f);	            
            }
		});
		$("#btn_reject").click(function(){
		    if(confirm("반려 하시겠습니까?"))
            {
	            $("#p_status").val("BB");
		        submitXmlRequest("/supplier/outside/SuppDeptRequest_form.screen", "DATA_REJECT", f);	            
            }
		});
		
		$("#btn_confim").click(function(){
		    
		    var u_email = $("#email");
		    //var u_phone = $('#user_phone');
		    
		    
		 	// 정규식 - 이메일 유효성 검사
	        var regEmail = /([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
		 
	     	// 정규식 -전화번호 유효성 검사
	        //var regPhone = /^((01[1|6|7|8|9])[1-9]+[0-9]{6,7})|(010[1-9][0-9]{7})$/;
	     	
	     	
	     	//입력값 체크
	     	if($("#corp_reg_no").val().trim() != "")
	     	{
	     	   	var regNum = /^[0-9]{10}$/;
	     	    
	     	    if(!regNum.test($("#corp_reg_no").val().trim()))
	     	    {
	     	       	alert("사업자 번호를 확인해 주세요.");
	     	      	$("#corp_reg_no").focus();
	                return false;
	     	    }
     	        
	     	}
	     	else
	     	{
	     	   alert("사업자 번호를 입력해 주세요");
	     	   $("#corp_reg_no").focus();
	     	   return false;
	     	}
	     	
	     	if($("#corp_kor").val().trim() == "")
	     	{
	     	   alert("업체명을 입력해 주세요");
	     	   $("#corp_kor").focus();
	     	   return false;ㄲ
	     	}
	     	else if($("#rep_name").val().trim() == "")
	     	{
	     	   alert("대표자명을 입력해 주세요");
	     	   $("#rep_name").focus();
	     	   return false;
	     	}
	     	else if($("#user_name").val().trim() == "")
	     	{
	     	   alert("담당자명을 입력해 주세요");
	     	   $("#user_name").focus();
	     	   return false;
	     	}

	        if(u_email.val().trim() == "")
	        {
	            alert("이메일주소를 입력 해 주세요");
	            u_email.focus();
	            return false;
	        } 
	        else 
	        {
	            if(!regEmail.test(u_email.val())) 
	            {
	                alert("이메일 주소가 유효하지 않습니다");
	                u_email.focus();
	                return false;
	            }
	        }
	        
	        if($("#CREDIT_CD").val().trim() == "")
	     	{
	     	   alert("신용평가사를 선택 해 주세요");
	     	   $("#CREDIT_CD").focus();
	     	   return false;
	     	}
	        if($("#CREDIT_CD").val().trim() != "Z" && $("#CREDIT_VALUE").val().trim() == "")
	     	{
	     	   alert("신용평가 등급을 선택 해 주세요");
	     	   $("#CREDIT_VALUE").focus();
	     	   return false;
	     	}
	        if($("#CREDIT_CD").val().trim() != "Z" && $("#CASH_GRADE").val().trim() == "")
	     	{
	     	   alert("현금흐름등급을 선택 해 주세요");
	     	   $("#CASH_GRADE").focus();
	     	   return false;
	     	}	        
	        if($("#debt_amt").val().trim() == "")      
	     	{
	     	   alert("부채총계를 입력해 주세요");
	     	   $("#debt_amt").focus();
	     	   return false;
	     	}
	        if($("#capital_amt").val().trim() == "")
	     	{
	     	   alert("자본총계를 입력해 주세요");
	     	   $("#capital_amt").focus();
	     	   return false;
	     	}
	        if($("#liquid_asset").val().trim() == "")
	     	{
	     	   alert("유동자산을 입력해 주세요");
	     	   $("#liquid_asset").focus();
	     	   return false;
	     	}
	        if($("#liquid_debt").val().trim() == "")
	     	{
	     	   alert("유동부채를 입력해 주세요");
	     	   $("#liquid_debt").focus();
	     	   return false;
	     	}
	        if($("#syear").val().trim() == "")
	     	{
	     	   alert("설립년도를 입력해 주세요");
	     	   $("#syear").focus();
	     	   return false;
	     	}
	     	
	        
	        if($("#hp1").val().trim() == "" || $("#hp2").val().trim() == "" || $("#hp3").val().trim() == "" )
	        {
	            alert("휴대전화 번호를 입력해 주시기 바랍니다.");
                return false;
	        }
	        
	        //첨부파일4개  "checkbox"
	        var f = document.form1 
	        if ( !f.p_100.checked && !f.p_110.checked && !f.p_120.checked )   
	        {
	            alert("첨부파일 한개이상 등록하십시요.");
                return false;
	        }
	        
	        if($("#REQ_REMARK").val().trim() == "")
	     	{
	     	   alert("추천사유를 입력해 주세요");
	     	   $("#REQ_REMARK").focus();
	     	   return false;
	     	}
	        
	        if($("#DEPT_NM").val().trim() == "")
	     	{
	     	   alert("추천부서를 입력해 주세요");
	     	   $("#DEPT_NM").focus();
	     	   return false;
	     	}
	        
	        if($("#REQ_EMP").val().trim() == "")
	     	{
	     	   alert("추천인을 입력해 주세요");
	     	   $("#REQ_EMP").focus();
	     	   return false;
	     	}
	        
	        var f = document.form1;
	        $("#flag").val("app");
	        $("#p_status").val("AA");
	        $("#fevent").val("CHK_APPVAR"); 
		    submitXmlRequest("/supplier/outside/SuppDeptRequest_form.screen", "CHK_APPVAR", f, "VALUEOBJECT");            
		    
		});
		
		
		
		
		$("#btn_save").click(function(){
		    
		    var u_email = $("#email");
		    
		    
		 	// 정규식 - 이메일 유효성 검사
	        var regEmail = /([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
		 
	     	//입력값 체크
	     	if($("#corp_reg_no").val().trim() != "")
	     	{
	     		var regNum = /^[0-9]{10}$/;
	     	   
	     	    if(!regNum.test($("#corp_reg_no").val().trim()))
	     	    {
	     	       	alert("사업자 번호를 확인해 주세요.");
	     	      	$("#corp_reg_no").focus();
	                return false;
	     	    }
	     	}
	     	else
	     	{
	     	   alert("사업자 번호를 입력해 주세요");
	     	   $("#corp_reg_no").focus();
	     	   return false;
	     	}
	     	
	     	if($("#corp_kor").val().trim() == "")
	     	{
	     	   alert("업체명을 입력해 주세요");
	     	   $("#corp_kor").focus();
	     	   return false;
	     	}
	     	
	     	
	     	if( confirm("저장 하시겠습니까? ") ){
	     		 if( status == "" ) {
		        	 $("#flag").val("insert");
		         }else{
		        	 $("#flag").val("update");
		         }
		         var f = document.form1;
		         $("#fevent").val("CHK_APPVAR"); 
				 submitXmlRequest("/supplier/outside/SuppDeptRequest_form.screen", "CHK_APPVAR", f, "VALUEOBJECT");
	     	}
		});		
		
		
		$("#btn_delete").click(function(){
		    if(confirm("삭제 하시겠습니까?"))
	        {
		    	 var f = document.form1;
		         $("#flag").val("delete");
	             $("#fevent").val("CHK_APPVAR"); 
			     submitXmlRequest("/supplier/outside/SuppDeptRequest_form.screen", "CHK_APPVAR", f, "VALUEOBJECT");   
	        }
		});
	});
	
	function doResult(resultObj) {
		try {
			if( resultObj.getRequestEvent() == "SAVE_DATA") {
				if( resultObj.getSuccess() ) 
				{
					document.form1.isSubmit = false;
					
					alert("저장 하였습니다.");		
					$("#fevent").val("");
					$("#form1").attr("action", "/supplier/outside/SuppDeptRequestList.screen");
					$("#form1").attr("target", "_self");
					$("#form1").attr("method", "post");
					$("#form1").submit();
				}
				else 
				{
					alert(resultObj.getValueObject().get("errMsg"));
					document.form1.isSubmit = false;
				}
			}
			else if(resultObj.getRequestEvent() == "UPDATE_DATA"){
				if( resultObj.getSuccess() ) 
				{
					document.form1.isSubmit = false;
					if(jQuery("#flag").val() == "update"){	    
						alert("저장 하였습니다.");	
					    $("#fevent").val("GET_DETAIL");
					    $("#form1").attr("action", "/supplier/outside/SuppDeptRequest.screen");
						$("#form1").submit();		
				    }else if(jQuery("#flag").val() == "app"){
					    var f = document.form1;   
			            var p_corp_id = f.p_corp_id.value; 	 
				        dlgSignForm('ebid_ocustD', '/supplier/outside/SuppRequestSign.screen?p_corp_id='+p_corp_id+'^acct_type=1^sign_type=1' );
				    }
				}else 
				{
					alert(resultObj.getValueObject().get("errMsg"));
					document.form1.isSubmit = false;
				}
				
			}   			
			else if( resultObj.getRequestEvent() == "CHK_APPVAR" ) {
				var vo = resultObj.getValueObject();
				var check = vo.get('cnt');
    			if(check == 0){	//가능
    				document.form1.isSubmit = false;    
    				var f = document.form1
    			    if(jQuery("#flag").val() == "insert"){
    			    	$("#fevent").val("SAVE_DATA");
    	        		$("#p_status").val("AA");
    		            submitXmlRequest("/supplier/outside/SuppDeptRequest_form.screen", "SAVE_DATA", f, "VALUEOBJECT");      		            
    	        	}else if(jQuery("#flag").val() == "update"){	    
						$("#fevent").val("UPDATE_DATA");
    	        		$("#p_status").val("AA");
    		            submitXmlRequest("/supplier/outside/SuppDeptRequest_form.screen", "UPDATE_DATA", f, "VALUEOBJECT"); 
    				}else if(jQuery("#flag").val() == "app"){
    					jQuery("#fevent").val("UPDATE_DATA");
    					$("#p_status").val("AA");
    					submitXmlRequest("/supplier/outside/SuppDeptRequest_form.screen", "UPDATE_DATA", f, "VALUEOBJECT");
    				}else if(jQuery("#flag").val() == "delete"){
    					jQuery("#fevent").val("DELETE_DATA");
    					submitXmlRequest("/supplier/outside/SuppDeptRequest_form.screen", "DELETE_DATA", f); 
    				}
				}else{
    				document.form1.isSubmit = false;
					alert("이미 결재중입니다.");
    			}
			}
			else if(resultObj.getRequestEvent() == "DELETE_DATA")
			{
			    if( resultObj.getSuccess() ) 
				{
					document.form1.isSubmit = false;
					
					alert("삭제 되었습니다.");
					
					$("#form1").attr("action", "/supplier/outside/SuppDeptRequestList.screen");
					$("#form1").attr("target", "_self");
					$("#form1").attr("method", "post");
					$("#form1").submit();
					
				}
				else 
				{
				    document.form1.isSubmit = false;
				    dlgErrorMsg(resultObj);
				}
			} 
			else if(resultObj.getRequestEvent() == "DATA_APP")
			{
			    if( resultObj.getSuccess() ) 
				{
					document.form1.isSubmit = false;
					
					alert("승인 되었습니다.");
					
					$("#form1").attr("action", "/supplier/outside/SuppDeptRequestList.screen");
					$("#form1").attr("target", "_self");
					$("#form1").attr("method", "post");
					$("#form1").submit();
					
				}
				else 
				{
				    document.form1.isSubmit = false;
				    dlgErrorMsg(resultObj);
				}
			} 
			else if(resultObj.getRequestEvent() == "DATA_REJECT")
			{
			    if( resultObj.getSuccess() ) 
				{
					document.form1.isSubmit = false;
					
					alert("반려 되었습니다.");
					
					$("#form1").attr("action", "/supplier/outside/SuppDeptRequestList.screen");
					$("#form1").attr("target", "_self");
					$("#form1").attr("method", "post");
					$("#form1").submit();
					
				}
				else 
				{
				    document.form1.isSubmit = false;
					alert("실패하였습니다.");
				}
			} 
			else if(resultObj.getRequestEvent() == "GET_ATTACHFILE")
	    	{
				if( resultObj.getSuccess() ) {				
					document.form1.p_AttachFile1.value = resultObj.getValueObject().get("SUPP_DEPT_REQ");
				}else {
					dlgErrorMsg(resultObj);
				}
				document.form1.isSubmit = false;
	    	}
		}
		catch(errorObject) {
			showErrorDlg("doResult()", errorObject);
		}
	}
	 
	//결재
	function dlgSignForm( sign_class_cd, uri ) {
		
		var f = document.form1;
		var sheet1 = document.all.sheet1;
		
		var url = "/slipSign/suppSign_form.screen";
		url += "?sign_class_cd=" + sign_class_cd;
		url += "&uri="  + uri;
		url += "&p_corp_id="  + f.p_corp_id.value;
		url += "&acct_type=1";
		
		if(confirm("결재 하시겠습니까?") ){
			window.open(url, "_blank","width=200,height=100,SCROLLBARS=no");
		}else{
			return;
		}
	}
	function fileCheck(val){
		var obj = eval("document.getElementById('" + val + "')");
		if(obj.style.display == "none"){
			obj.style.display = "inline";
		}else{
			obj.style.display = "none";
		}
	}
    
	function doAttachFile(obj, No, fileName ) {
		if(obj.value == ''){
			alert("데이터를 저장 후, 파일을 첨부할 수가 있습니다.");
		}
		else if(obj.value != ''){
			var upLoadFlg = "Y";
			if("<%=vo.get("STATUS_CODE")%>" == "00" || "<%=vo.get("STATUS_CODE")%>" == "03"){
				upLoadFlg = "N";
			}
			<% if ( !vo.get("cre_by").equals(user.get("acct_id")) && vo.get("STATUS_CODE") != "") {%>
			     upLoadFlg = "N";
			<%}%>
		 	
			viewFileListNew1('SUPP_DEPT_REQ_'+obj.value, No, document.form1.p_AttachFile2, upLoadFlg, "own/outside/req/"+obj.value, null, fileName) ; 
		} 
	}

	function getFileListForTextarea(){
		document.form1.p_AttachFile1.value = "";
		var f = document.form1;  
		jQuery("#fevent").val("GET_ATTACHFILE");
		submitXmlRequest("/supplier/outside/SuppDeptRequest_form.screen", "GET_ATTACHFILE", f, "VALUEOBJECT");	 
	} 
	
	function debt_rate(){
		var debt_amt = $("#debt_amt").val();
	
		if(debt_amt == "")
			debt_amt = 0;
		else
			debt_amt = debt_amt.replace(/,/gi,"");
	
		var capital_amt = $("#capital_amt").val();
		if(capital_amt == "")
			capital_amt = 0;
		else
			capital_amt = capital_amt.replace(/,/gi,"");
		
		if(debt_amt > 0 && capital_amt > 0){
			var rate = Number(debt_amt)/Number(capital_amt) * 100;
			$("#debt_rate").val(Math.round(rate *100)/100);
			if (rate >= 250){
				document.getElementById('debt_rate1').innerHTML = "<font color='red'>" + Math.round(rate *100)/100 + "</font>";  
			}else{
				document.getElementById('debt_rate1').innerHTML =  Math.round(rate *100)/100;
			}
			 
		}else{
			document.getElementById('debt_rate1').innerHTML = "";
		}
	}
	
	function liquid_rate(){
		var liquid_asset = $("#liquid_asset").val();
		if(liquid_asset == "")
			liquid_asset = 0;
		else
			liquid_asset = liquid_asset.replace(/,/gi,"");
		var liquid_debt = $("#liquid_debt").val();
		if(liquid_debt == "")
			liquid_debt = 0;
		else
			liquid_debt = liquid_debt.replace(/,/gi,"");
		
		if(liquid_asset > 0 && liquid_debt > 0){
			var rate = Number(liquid_asset)/Number(liquid_debt) * 100;
			$("#liquid_rate").val(Math.round(rate *100)/100);
			if (rate < 100) {
				document.getElementById('liquid_rate1').innerHTML = "<font color='red'>" + Math.round(rate *100)/100 + "</font>";  
			}else{
				document.getElementById('liquid_rate1').innerHTML =  Math.round(rate *100)/100;
			}			 
		}else{
			document.getElementById('liquid_rate1').innerHTML = "";
		}		
	}
	function syear(){
		var syear = $("#syear").val();
		if(syear == "")
			syear = 0;
		
		if(syear > 0){
			var rate = Number("<%= nyear%>") - Number(syear) ;
			if (rate <= 2 ) {
				document.getElementById('syear1').innerHTML = "영업기간 2년미만";  
			}else{
				document.getElementById('syear1').innerHTML =  "";
			}
			 
		}else{
			document.getElementById('syear1').innerHTML = "";
		}
		
	}
	function LICENCE_YN(){
        if ($(':radio[name="LICENCE_YN"]:checked').val() == "N")  {
			document.getElementById('LICENCE_YN_TEXT').innerHTML = "<font color='red'><b>" + "미보유" + "</b></font>";  
		}else{
			document.getElementById('LICENCE_YN_TEXT').innerHTML =  "미보유";  
		}
	}
	function CREDIT_VALUE(){
	
        if (($("#CREDIT_VALUE").val().substring(0,1)  > "C") || ($("#CASH_GRADE").val().substring(0,1)  > "C"))  {
			document.getElementById('CREDIT_VALUE1').innerHTML = "<font color='red'>" + "신용평가등급" + "</font>";  
		}else{
			document.getElementById('CREDIT_VALUE1').innerHTML =  "신용평가등급";  
		}
	}
	
	
	function viewFileListNew1(fileGB, id, obj, isModify, isDrectory, iframeID, user_filename) {
		
		var win_id = "_viewFileList";
		var link = "/common/file/FileListNew.screen";
		    link += "?pop_win_id="+win_id;
		    link += "&extFunction=viewFileListClose1";
		    link += "&file_gb=" + fileGB;
		    link += "&id=" + id;
		    
		    if( obj.id != null )
			    link += "&obj_id=" + obj.id;
		    if( iframeID != null )
		    	link += "&iframeID=" + iframeID;
		    
			if( isModify != null )
				link += "&is_modify=" + isModify;
			if( isDrectory != null )
				link += "&sys_gb=" + isDrectory;	    
			if( user_filename != null )
				link += "&user_filename=" + user_filename;	 
		fLayerPop(win_id, link, 750,430, '', '', 'NO', '200');
	}
	function PopClose(win_id,result){
	alert(99999);
	}
 
	 function doAppFile(doc_id){
		if(doc_id == ""){
			alert("결재 정보가 없습니다.");
			return;
		}
		var doc_chk = doc_id.substring(doc_id.length-3, doc_id.length);
		
		doc_chk = doc_chk * 1;
		
		var link = "";
		var year = "<%=vo.get("year") %>";
		link = "<%=gwurl%>upload_approval/TEC/doc/" + year.substr(0,4) + "/" + doc_chk + "/"+ doc_id+".mht";
		
		window.open(link,"_viewDraft","");	
	}  
	 
	 function setCreditValue(){
		 if($("#CREDIT_CD").val().trim() == "Z" ){
			 $("#CREDIT_VALUE").val("");
			 $("#CREDIT_VALUE").attr("disabled", true);
			 $("#CASH_GRADE").val("");
			 $("#CASH_GRADE").attr("disabled", true);			 
		 }else{
			 $("#CREDIT_VALUE").attr("disabled", false);
			 $("#CASH_GRADE").attr("disabled", false);
		 }
	}  
	 
			 
	 function SearchUser(NAME,CODE,DEPT_YN){
			 
			GB = "";
			var win_id = "_searchUserPopup";
			var link = "/lib/dlgSearchUserPop.screen";
			    link += "?pop_win_id="+win_id;
			    link += "&NAME="+NAME;
			    link += "&CODE="+CODE;
			    link += "&GB="+GB;
			fLayerPop(win_id, link, 700,400, '', '', 'NO');
		}
	 
	 function SearchUserClose(result){
		   $("#REQ_EMP").val(result[1])//이름
		   $("#DEPT_NM").val(result[3])//부서
		   //$("#REQ_EMP").val(result[0])//사번
		   
		   setTimeout(function(){	fLayerPopClose('_searchUserPopup');},100);
		}
		
</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="p_corp_id" id="p_corp_id" value="<%=params.get("p_corp_id") %>" />
<INPUT type="hidden" name="job_div" id="job_div" value="O" />
<INPUT type="hidden" name="p_status" id="p_status" value="" /> 
<INPUT type="hidden" name="debt_rate" id="debt_rate"  value="<%=vo.get("debt_rate") %>"/> 
<INPUT type="hidden" name="liquid_rate" id="liquid_rate" value="<%=vo.get("liquid_rate") %>" /> 
<INPUT type="hidden" name="p_AttachFile2" id="p_AttachFile2" onPropertyChange="JavaScript:getFileListForTextarea();" />
<INPUT type="hidden" name="flag" id="flag" value="">

<!-- 목록 파라메터 -->
<INPUT type="hidden" name="corp_no" id="corp_no" value="<%=params.get("corp_no") %>" />
<INPUT type="hidden" name="corp_name" id="corp_name" value="<%=params.get("corp_name") %>" />
<INPUT type="hidden" name="corp_status" id="corp_status" value="<%=params.get("corp_status") %>" />
 

<table border="0" cellspacing="0" cellpadding="0" style="width: 100%;">
	<tr>
		<td style="text-align: left;">
			<div align="left" id="title" style="float: left;">
				<ul>
			    	<li><%=job_gubun %>_협력업체가입요청 상세(<%=vo.get("status").equals("") ? "작성중" : vo.get("status")%>)</li>
			    	<li>
			   	</ul>
			</div> 
		</td>
		<td style="text-align: right; vertical-align: bottom;">
			<span class="btnSearch center"><a href="javascript:void(0);" id="btn_list">목록</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="btn_delete_area"><a href="javascript:void(0);" id="btn_delete">삭제</a></span>
			<span class="btnSearch center" id="btn_confim_area"><a href="javascript:void(0);" id="btn_confim">결재</a></span>
			<span class="btnSearch center" id="btn_approval_area"><a href="javascript:void(0);" id="btn_approval">승인</a></span>
			<span class="btnSearch center" id="btn_reject_area"><a href="javascript:void(0);" id="btn_reject">반려</a></span>
		</td>
	</tr>
</table>

<!-- 발주의뢰정보 : 시작 -->
<div class="application-info magT10">
	<div class="application-sub-title">
		<span class="title">회사정보</span>
	</div>
</div>
<table cellspacing="1" cellpadding="0" class="form-table">
	<colgroup>
	<col width="100px"/>
	<col WIDTH="25%"/>
	<col width="100px"/>
	<col WIDTH="25%"/>
	<col width="100px"/>
	<col WIDTH="25%"/>
	</colgroup>
				<!-- 검색조건 타이틀 1 -->
	<TH class="required">
		사업자번호
	</th>
	<td> 
	<input type="text" name="corp_reg_no" id="corp_reg_no" numberOnly="true" SIZE="13" maxlength="10" value="<%=vo.get("corp_reg_no")%>" />(숫자만입력)
 
	</td>
			<TH class="required">
	   			업체명
			</th>
			<td>
				<input type="text" name="corp_kor" id="corp_kor" style="width: 85%;"  value="<%=vo.get("corp_kor")%>" />
			</td>
			<TH class="required">
	   			대표자명
			</th>
			<td>
				<input type="text" name="rep_name" id="rep_name" maxlength="30" style="width: 85%;"  value="<%=vo.get("rep_name")%>"/>
	        </td>
	</tr>
	<tr height="25"> 
    				<TH class="required">
    					담당자명
    				</th>
   					<td class="search_table_data">
  						<input type="text" name="user_name" id="user_name" style="width: 85%;" value="<%=vo.get("user_name")%>"/>
					</td>
    				<TH class="required">
        				이메일
    				</th>
    				<td class="search_table_data">
    					<input type="text" name="email" id="email" style="width: 85%;ime-mode:inactive"  value="<%=vo.get("email")%>"/>
    				</td>
    				<TH class="required">
        				휴대전화
    				</th>
    				<td class="search_table_data">
    					<input type="text" name="hp1" id="hp1" SIZE="3" numberOnly="true" maxlength="3" value="<%=vo.get("HP1")%>"/> -
    					<input type="text" name="hp2" id="hp2" SIZE="4" numberOnly="true" maxlength="4" value="<%=vo.get("hp2")%>"/> - 
    					<input type="text" name="hp3" id="hp3" SIZE="4" numberOnly="true" maxlength="4" value="<%=vo.get("hp3")%>"/> 
    				</td>
  				</tr>
	<tr height="25"> 
	<th class="required">
	     <b><span id="CREDIT_VALUE1"></span></b>
	</th>
	<td COLSPAN="3">
	      <%=CommCodeManager.getSelectCodeList("CREDIT_CD","CREDIT_CD","height=18;","<option value=''>--선택--</option>",vo.get("CREDIT_CD"), " onchange='setCreditValue();'") %>&nbsp;
	      <span>신용등급</span>	
	      <%=CommCodeManager.getSelectCodeList("CREDIT_VALUE","CREDIT_VALUE","height=18;","<option value=''>--선택--</option>",vo.get("CREDIT_VALUE")) %>&nbsp;
	      <span>현금흐름등급</span>
	      <%=CommCodeManager.getSelectCodeList("CASH_GRADE","CASH_GRADE","height=18;","<option value=''>--선택--</option>",vo.get("CASH_GRADE")) %> 
	</td>
	<th class="required">
	      설립년도
	</th>
	<td>
			<input type="text" name="syear" id="syear" SIZE="10" numberOnly="true" maxlength="4" value="<%=vo.get("syear")%>"/>
			<b><font color='red'><span id="syear1"></span></font></b>
	</td>
	</tr>
	<tr height="25"> 
	<th class="required">
	      부채총계
	</th>
	<td>
			<%= InputText.get("debt_amt", Formatter2.currency(vo.get("debt_amt"),0), 13, 300, "desc=부채총계,Number,right","Number") %>
	</td>
	<th class="required">
	      자본총계
	</th>
	<td>
			<%= InputText.get("capital_amt", Formatter2.currency(vo.get("capital_amt"),0), 13, 300, "desc=자본총계,Number,right","Number") %>
	</td>
	<th>
	      부채비율
	</th>
	<td>
	  	 <b><span id="debt_rate1"></span>%</b>(부채총계/자본총계)
	</td>
	</tr>
	<tr height="25">
	<th class="required">
	      유동자산
	</th>
	<td>
		    <%= InputText.get("liquid_asset", Formatter2.currency(vo.get("liquid_asset"),0), 13, 300, "desc=유동자산,Number,right","Number") %>
    </td>
	<th class="required"> 
	      유동부채
	</th>
	<td>
		    <%= InputText.get("liquid_debt", Formatter2.currency(vo.get("liquid_debt"),0), 13, 300, "desc=유동부채,Number,right","Number") %>
    </td>
	<th>
	      유동비율
	</th>
	<td>
		    <b><span id="liquid_rate1"></span>%</b>(유동자산/유동부채) 
    </td>	
	</tr>
	<tr height="25"> 
	<th class="required">
	      건설업면허
	</th>
	<%-- <% if ( user.get("RIGHT_NAME").equals("OUTSIDE") || user.get("RIGHT_NAME").equals("ADMIN NEW") ) {%> --%>
	    <td>
			 <LABEL for="LICENCE_YN1"><INPUT id="LICENCE_YN1" type="radio" name="LICENCE_YN" value="Y" desc="건설업면허" <%=vo.get("LICENCE_YN").equals("Y") ? "checked=\"checked\"" : "" %>> 보유</LABEL>
	         <LABEL for="LICENCE_YN2"><INPUT id="LICENCE_YN2" type="radio" name="LICENCE_YN" value="N" desc="건설업면허" <%=vo.get("LICENCE_YN").equals("N") ? "checked=\"checked\"" : "" %>> </LABEL><span id="LICENCE_YN_TEXT"></span>
			 <LABEL for="LICENCE_YN3"><INPUT id="LICENCE_YN3" type="radio" name="LICENCE_YN" value="T" desc="장비임대/설계/인허가" <%=vo.get("LICENCE_YN").equals("T") ? "checked=\"checked\"" : "" %>> 장비임대/설계/인허가</LABEL>
		</td>
		<th>
	                   결재정보
	    </th>
	    <td>
		     <img id="search_spot_button" src='/img/buyer/button/bt_change.gif' border='0'  align="top" align='absmiddle' alt='[Approval File]'  onClick='doAppFile("<%= vo.get("doc_id") %>");' style='cursor:pointer;'>
		</td>
		<th>
	                   작성자
	    </th>
	    <td>
		      <%= vo.get("WRITE_NAME") %>&nbsp;
		</td>
	<%-- <% }
	else{%>
	    <td COLSPAN="5">
			 <LABEL for="LICENCE_YN1"><INPUT id="LICENCE_YN1" type="radio" name="LICENCE_YN" value="Y" desc="건설업면허" <%=vo.get("LICENCE_YN").equals("Y") ? "checked=\"checked\"" : "" %>> 보유</LABEL>
	         <LABEL for="LICENCE_YN2"><INPUT id="LICENCE_YN2" type="radio" name="LICENCE_YN" value="N" desc="건설업면허" <%=vo.get("LICENCE_YN").equals("N") ? "checked=\"checked\"" : "" %>> </LABEL><span id="LICENCE_YN_TEXT"></span>
			 <LABEL for="LICENCE_YN3"><INPUT id="LICENCE_YN3" type="radio" name="LICENCE_YN" value="T" desc="장비임대/설계/인허가" <%=vo.get("LICENCE_YN").equals("T") ? "checked=\"checked\"" : "" %>> 장비임대/설계/인허가</LABEL>
		</td>
	<%} %>  --%>
	
	</tr>
</table>
<br>
<font color="red"><b>
※ 신용평가등급 B- 미만 또는 미발급업체 / 부채비율 250% 이상 / 유동비율 100% 이하 / 영업기간 2년 미만 / 건설업면허 미보유 공사업체의 경우, <u>협력업체 등록이 제한</u>될 수 있습니다.
<br>
<br>
※ 신규 협력업체 등록 요청은 전결규정에 의거, 담당임원까지 결재 받으시기 바랍니다. </b> </font>  
<div class="application-info magT20">
	<div class="application-sub-title">
		<span class="title">요청정보</span>
	</div>
</div>
<table cellspacing="1" cellpadding="0" class="form-table">
	<colgroup>
	<col width="100px"/>
	<col WIDTH="25%"/>
	<col width="100px"/>
	<col WIDTH="25%"/>
	<col width="100px"/>
	<col WIDTH="25%"/>
	</colgroup>
				
				<tr height="25"> 
    				<TH class="required">
    					추천부서
    				</th>
   					<td class="search_table_data">
  						<input type="text" name="DEPT_NM" id="DEPT_NM" maxlength="66"  style="width: 95%;" value="<%=vo.get("DEPT_NM")%>"  />
					</td>
    				<TH class="required">
        				추천인
    				</th>
    				<td class="search_table_data">
    					<input type="text" name="REQ_EMP" id="REQ_EMP" maxlength="16"  style="width: 75%;ime-mode:inactive"  value="<%=vo.get("REQ_EMP")%>"   />
    					<IMG id=btnevalemp src="/img/buyer/button/bt_search_right.gif" alt="추천인" border="0" align="absmiddle" style="cursor:pointer;" onClick="JavaScript:SearchUser('','','N');">
    				</td>
    				<TH class="required">
        				추천일자
    				</th>
    				<td class="search_table_data">
    					<%=vo.get("REQ_DATE")%>
    				</td>
    			<TR>
    			<tr height="25"> 
    				<TH class="required"><!-- wrap=off -->
        				추천사유<br>(상세기술)
    				</th>
    				<td class="search_table_data"  colspan="3">
    				 	<textarea name="REQ_REMARK" id="REQ_REMARK" style="width:95%;height:80px;overflow:scroll;" rows="1" class="input" > <%=vo.get("REQ_REMARK")%></textarea>
					</td>
					<TH class="required">
        				반려사유
    				</th>
    				<td class="search_table_data" >
    				 	<textarea name="REJECT_REASON" id="REJECT_REASON" style="width:95%;height:80px" rows="1" class="input"  ><%=vo.get("REJECT_REASON")%></textarea>
					</td>
  				</tr>
  				<tr height="70"> 
    				<TH class="required">
        				첨부파일
    				</th>
    				<td class="search_table_data" colspan="3">
    				<table border=0 >
    				<%
							if(getFileListRowSet.size() > 0){
								
								int i_mod = 0;
								for(int i = 0; getFileListRowSet.size() > i; i++){
									i_mod = i%2;
									if(i_mod == 0){ %>
										<TR>
								<%	} %>
											<td width="10px">
											<input type="checkbox" name="p_<%=getFileListRowSet.getRow(i).get("DETAILCD") %>" id="p_<%=getFileListRowSet.getRow(i).get("DETAILCD") %>" value="<%=getFileListRowSet.getRow(i).get("DETAILCD") %>" style="cursor:pointer;" onClick="fileCheck('<%=getFileListRowSet.getRow(i).get("DETAILCD") %>')" <%if(!getFileListRowSet.getRow(i).get("DOC_CD").equals("")){out.print("checked");} %> >
											</td>
											<td width="200px">
											<%=getFileListRowSet.getRow(i).get("DETAILNM") %>
											</td>
											<td width="30px" height="24">
											<IMG src="/img/supplier/button/bt_attach_file.gif" id="<%=getFileListRowSet.getRow(i).get("DETAILCD") %>" alt="첨부파일 관리" align="top" style="display:<%if(!getFileListRowSet.getRow(i).get("DOC_CD").equals("")){out.print("inline");}else{out.print("none");} %>" onClick="doAttachFile(document.form1.p_corp_id, '<%=getFileListRowSet.getRow(i).get("DETAILCD") %>', '<%=getFileListRowSet.getRow(i).get("DETAILNM")%>');" class="button">
											</td>
								<%	if(i_mod == 1) { %>		
										</TR>
								<%	} %>		
							<%
								}								
							}
						%>
						</table>
    					
					</td>
					<td colspan="2" >
						<textarea name="p_AttachFile1" id="p_AttachFile1" style="width:98%;height:100px" rows="1" class="input" readOnly></textarea>
					</td>
  				</tr>
  				 
</table>

</form>