<%--
  - Author(s)  : chj
  - Date       : 2015.04.17
  - Description: 외주 하수급인 신청서
  --%>
  
<%@page import="java.sql.Clob"%>
<%@ page contentType="text/html; charset=utf-8" %>
<%@ page import="com.udapsoft.waf.system.HandlerStorage" %>
<%@ page import="com.udapsoft.waf.common.ui.*" %>
<%@ page import="com.udapsoft.waf.common.util.*" %>
<%@ page import="kr.co.hsnc.common.util.*"%>
<%@ page import="kr.co.hsnc.common.sql.*" %>
<%@ page import="kr.co.hsnc.common.config.WAFConfig" %>
<%@ include file="/jsp/work/taglib.jsp" %>
<%@ page import="kr.co.hsnc.common.util.Formatter"%>
<%@page import="java.net.URLEncoder"%>
<%@ page import="kr.co.udapsoft.ebid.buyer.common.file.FileManager"%>
<jsp:useBean id="ctx" class="com.udapsoft.waf.system.context.SessionContext" scope="session" />
<%
    ctx.init(request, response);
    HandlerStorage storage = ctx.getHandlerStorage();
    ValueObject params = storage.getParams();
    ValueObject user = storage.getUser();
    ValueObject ContInfo = storage.getValueObject("ContInfo");
%>
<SCRIPT language="JavaScript">
/*예약함수*/
	
	var must_msg = "(은)는 필수 입력 항목입니다.";
	var btn_act;
	
	function _onReady(){
		
		if(<%=!ContInfo.get("INSUR_STATUS_CD").equals("01") %> &&  <%=!ContInfo.get("INSUR_STATUS_CD").equals("09") %>){
			jQuery("#btnSave").hide();
			jQuery("#btnDeci").hide();
			jQuery("#btnDel").hide();
		}
		//2017.04.14 삭제기능추가
		jQuery("#btnDel").click(function(){
			var f = document.form1;
			submitXmlRequest("/cont/outside/ContResultInsur_form.screen", "CHK", f, "SUCCESS");
			btn_act = "to_del";	
		});
		
		jQuery("#btnSave").click(function(){
			var f = document.form1;
			submitXmlRequest("/cont/outside/ContResultInsur_form.screen", "CHK", f, "SUCCESS");
			btn_act = "to_save";		
		});
		
		jQuery("#btnDeci").click(function(){
			var f = document.form1;
			submitXmlRequest("/cont/outside/ContResultInsur_form.screen", "CHK", f, "SUCCESS");
			btn_act = "to_deci";		
		});
		
		jQuery("#btnList").click(function(){
			goListProc();
		});
		
		
		jQuery("#MTIL_AMT").blur(function () {
			var mtilAmt = jQuery("#MTIL_AMT").val().replace(/(\,|\:)/g,"");	
			var digit = jQuery("#sosuNum").val();
			
			jQuery("#MTIL_AMT").val(Number(mtilAmt).toFixed(digit));
			
			jQuery("#MTIL_AMT").each(function(index){
				 jQuery(this).val(jQuery(this).val().split(/(?=(?:\d{3})+(?:\.|$))/g).join(','));  
			});
		});
	} 

	function goListProc(){
		 var f = document.form1;
		f.fevent.value ="FORM_SELECT";
	    f.action = "/cont/outside/ContResult.screen";
	    f.target = "_self";
	    f.submit();
	}
	
	
	
	function must_ck(){
		if(must_ck_val("WORK_MNGR_NO",""))return false;
		
		if(!jQuery('input:checkbox[name="INSUR_EMPL_YN"]').is(":checked") && !jQuery('input:checkbox[name="INSUR_ACC_YN"]').is(":checked")){
			alert("보험종류 (은)는 필수 입력 항목입니다.")
			return false;			
		}else{
			if(jQuery(':checkbox[name="INSUR_EMPL_YN"]:checked').val() != "Y")$("#INSUR_EMPL_YN").val("N");
			if(jQuery(':checkbox[name="INSUR_ACC_YN"]:checked').val() != "Y")$("#INSUR_ACC_YN").val("N");
		}

		if(must_ck_val("BIZ_REG_NO",""))return false;
		//if(must_ck_val("CORP_REG_NO",""))return false;
		if(must_ck_val("SUB_PLACE_NO",""))return false;
		if(must_ck_val("LCNS_NM",""))return false;
		if(must_ck_val("LCNS_REG_NO",""))return false;
		if(must_ck_val("LCNS_ACQT_DATE",""))return false;
		if(must_ck_val("MTIL_AMT",""))return false;
		if(must_ck_val("INSUR_WORK_PLACE",""))return false;
		
		return true;
	}
	
	// value 값 체크 
	function must_ck_val(obj,desc){
		if(jQuery("#"+obj).val().length == 0){
			if(desc.length> 0){
				alert(desc+must_msg);
			}else{
				alert(jQuery("#"+obj).attr("desc")+must_msg);
			}
			jQuery("#"+obj).focus();
			return true;
		}
		return false;
	}
	
	function doResult(resultObj) {
		try {
			if( resultObj.getRequestEvent() == "CHK") {
				if( resultObj.getSuccess() ) {
					document.form1.isSubmit = false;
					if(btn_act == "to_save"){
						
						if(jQuery(':checkbox[name="INSUR_EMPL_YN"]:checked').val() != "Y")$("#INSUR_EMPL_YN").val("N");
						if(jQuery(':checkbox[name="INSUR_ACC_YN"]:checked').val() != "Y")$("#INSUR_ACC_YN").val("N");

						var f = document.form1;
						submitXmlRequest("/cont/outside/ContResultInsur_form.screen", "SAVE_INSUR_DATA", f);
					}else if(btn_act == "to_deci"){
						if(must_ck()){
							if (confirm("결재 하시겠습니까?")){
								var f = document.form1;
								submitXmlRequest("/cont/outside/ContResultInsur_form.screen", "SAVE_INSUR_DATA", f);
							}
						}
					}else if(btn_act == "to_del"){
							if (confirm("삭제 하시겠습니까?")){
								var f = document.form1;
								submitXmlRequest("/cont/outside/ContResultInsur_form.screen", "DEL_INSUR_DATA", f);
							}
						
					}
				} else {
					alert("결재중입니다.");
				}
			}
			if( resultObj.getRequestEvent() == "SAVE_INSUR_DATA") {
				if( resultObj.getSuccess() ) {
					document.form1.isSubmit = false;
					if(btn_act == "to_deci"){
						var f = document.form1;
						var sign_key1 = $("#SUB_CONT_MOD_ID").val();
						dlgSignForm('ebid_obappD', '/cont/outside/ContInsurSign.screen?sign_key1='+sign_key1+'^sign_key2=O^acct_id='+"<%=user.get("ACCT_ID")%>");
					}else{
						alert("저장되었습니다.");
					}
				} else {
					dlgErrorMsg(resultObj);
				}
			}
			if( resultObj.getRequestEvent() == "DEL_INSUR_DATA") {
				if( resultObj.getSuccess() ) {
					document.form1.isSubmit = false;
					alert("삭제되었습니다.");	
					goListProc();
					
				} 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 = "/contOutsideInsurSign/contInsurSign_form.screen";
		url += "?sign_class_cd=" + sign_class_cd;
		url += "&uri="           + uri;
		url += "&sign_key1="   + $("#SUB_CONT_MOD_ID").val();
		url += "&sign_key2=O";
		url += "&acct_type=1";
		window.open(url, "_blank","width=200,height=100,SCROLLBARS=no");
	}
	
	function corpPopup(corpID){
		var url = "/cont/outside/ContTargetPopup.screen";
		url += "?p_corp_id=" + corpID;
		url += "&sModule="+"LM";
		
		window.open(url, "_ContTargetPop","width=1000,height=650,SCROLLBARS=no"); 
	}

</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="acct_id" value="<%= params.get("acct_id") %>">
<!-- 검색 조건 시작-->
<INPUT type="hidden" name="p_dept_cd" value="<%= params.get("p_dept_cd") %>">
<INPUT type="hidden" name="p_dept_nm" value="<%= params.get("p_dept_nm") %>">
<INPUT type="hidden" name="p_dealer_nm" value="<%= params.get("p_dealer_nm") %>">
<INPUT type="hidden" name="p_cont_status" value="<%= params.get("p_cont_status") %>">
<INPUT type="hidden" name="ContFromDt" value="<%= params.get("ContFromDt") %>">
<INPUT type="hidden" name="ContToDt" value="<%= params.get("ContToDt") %>">
<INPUT type="hidden" name="p_build_nm" value="<%= params.get("p_build_nm") %>">
<!-- 검색 조건 끝-->
<INPUT type="hidden" name="CONT_STATUS" value="<%=ContInfo.get("CONT_STATUS")%>">
<INPUT type="hidden" name="SUB_CONT_MOD_ID" value="<%=ContInfo.get("SUB_CONT_MOD_ID")%>">
<INPUT type="hidden" name="O_CORP_ID" value="<%=ContInfo.get("O_CORP_ID")%>">
<INPUT type="hidden" name="C_CORP_ID" value="<%=ContInfo.get("C_CORP_ID")%>">
<INPUT type="hidden" name="STATUS_CD" value="<%=ContInfo.get("STATUS_CD")%>">
<INPUT type="hidden" name="O_VENDCD" value="<%=ContInfo.get("O_VENDCD")%>">

<INPUT type="hidden" name="ChgCont" value="<%= params.get("ChgCont") %>">
<INPUT type="hidden" name="TEMPLATE_NAME" value="<%=params.get("template_name")%>">

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


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

	<!-- 제목 및 버튼 -->
<table width="100%">
	<colgroup>
		<col width="500" />
		<col width="*" />
	</colgroup>
	<tr>
	   	<th>
		   <div align="left" id="title">
		    <ul>
		     <li>외주_하수급인 신청서</li>
		    </ul>
		   </div>
	   </th>
	   <td align="right">
	        <span class="btnSearch center" id="btnDel"><a href="javascript:void(0);">삭제</a></span>
			<span class="btnSearch center" id="btnSave"><a href="javascript:void(0);">저장</a></span>
			<span class="btnSearch center" id="btnDeci"><a href="javascript:void(0);">결재</a></span>
			<span class="btnSearch center" id="btnList"><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 class="application-location">
	</div>
</div>
<TABLE class="form-table">
	<colgroup>
		<col width="130px" />
		<col width="24%"/>
		<col width="130px" />
		<col width="24%"/>
		<col width="130px" />
		<col/>
	</colgroup>
  <TR height="25"> 
    <TH>현장명</TH>
	<TD><%= ContInfo.get("DEPT_NAME")%></TD>	
	<TH>발주의뢰번호</TH>
	<TD><%=ContInfo.get("DEMANDED_NO")%></TD>
	<TH>발주의뢰자</TH>
	<TD><%= ContInfo.get("EMP_NM")%></TD> 	
  </TR>
  <TR height="25"> 
	<TH>발주의뢰일</TH>
	<TD><%= ContInfo.get("DEMANDED_DATE")%></TD> 
	<TH>발주의뢰부서</TH>
	<TD><%= ContInfo.get("REQ_DEPT_NM")%></TD>
	<TH>공종</TH>
	<TD><%= ContInfo.get("OUT_ITEM_NM")%></TD>	
  </TR> 	
  <TR height="25"> 
	<TH>계약명</TH>
	<TD colspan="3"><%= ContInfo.get("BUILD_NAME")%></TD>
	<TH>통화구분</TH>
	<TD><%= ContInfo.get("CON_CUR_CD")%><INPUT TYPE="hidden" name="sosuNum" ID="sosuNum" value="<%= ContInfo.get("SOSUNUM")%>">	
  </TR>	
  <TR height="25"> 
	<TH>전자계약 여부</TH>
	<TD colspan="5"> 
		<%=ContInfo.get("ELEC_CON_YN").equals("Y") ? "온라인" : "오프라인" %>
	</TD>
  </TR>
</TABLE>

<div class="application-info  magT10">
	<div class="application-sub-title">
		<span class="title">당사정보(원사업자) </span><font color="red">*필수입력항목</font>
	</div>
	<div class="application-location">
	<%if (!ContInfo.get("O_SIGN_DATE").equals("")){%> 
		서명일시 : <%= ContInfo.get("O_SIGN_DATE") %> 
	<%}%>		
	</div>
</div>
<TABLE class="form-table">
	<colgroup>
		<col width="130px" />
		<col width="24%"/>
		<col width="130px" />
		<col width="24%"/>
		<col width="130px" />
		<col/>
	</colgroup>
  <TR height="25"> 
	<TH>업체명</TH>
	<TD colspan="3"><%= ContInfo.get("O_MEMBER_NAME")%></TD>   
	<TH>대표자명</TH>
	<TD><%= ContInfo.get("O_BOSS_NAME")%></TD> 	
  </TR>
  <TR height="25"> 
	<TH>주소</TH>
	<TD colspan="3"><%= ContInfo.get("O_ADDRESS")%></TD> 
	<TH>승인자</TH>
	<TD>
	  <%= ContInfo.get("CON_CONFIRM_NAME")%>
 	</TD>         
  </TR>
  <TR height="25"> 
	<TH>담당부서</TH>
	<TD><%= ContInfo.get("O_DIVISION")%></TD>    
	<TH>담당자명</TH>
	<TD>
	  <%= ContInfo.get("O_USER_NAME")%>
 	</TD>         
	<TH>직급</TH>
	<TD><%= ContInfo.get("O_POSITION")%></TD>
  </TR>
  <TR height="25"> 
	<TH>담당자 연락처</TH>
	<TD><%= ContInfo.get("O_TEL_NUM")%></TD>
 	<TH>담당자 HP</TH>
	<TD><%= ContInfo.get("O_HP")%></TD>
	<TH>담당자 EMAIL</TH>
	<TD><%= ContInfo.get("O_EMAIL")%></TD> 	
  </TR>  
  <TR height="25">
  	<TH class="required">사업장 관리 번호</TH>
  	<TD>
  		<%= InputText.get("WORK_MNGR_NO", ContInfo.get("WORK_MNGR_NO"), 98, 30, "required,desc=사업장 관리 번호,persize") %>
  	</TD>
  	<TH class="required">보험종류</TH>
  	<TD colspan="3">
  		<LABEL for="INSUR_YN"><INPUT type="checkbox" id="INSUR_EMPL_YN" name="INSUR_EMPL_YN" value="Y" <%=ContInfo.get("INSUR_EMPL_YN").equals("Y") ? "checked=\"checked\"" : "" %>>&nbsp;고용보험&nbsp;</LABEL>
  		<LABEL for="INSUR_YN"><INPUT type="checkbox" id="INSUR_ACC_YN" name="INSUR_ACC_YN" value="Y" <%=ContInfo.get("INSUR_ACC_YN").equals("Y") ? "checked=\"checked\"" : "" %>>&nbsp;산재보험&nbsp;</LABEL>
  	</TD>
  	
  <!-- 계약정보 : 종료 -->
</table>
<div class="application-info  magT10">
	<div class="application-sub-title">
		<span class="title">계약업체정보(수급 사업자) </span><font color="red">*필수입력항목</font>
	</div>
	<div class="application-location">
	<%if (!ContInfo.get("C_SIGN_DATE").equals("")){%> 
		서명일시 : <%= ContInfo.get("C_SIGN_DATE") %> 
	<%}%>
	</div>
</div>
<TABLE class="form-table">
	<colgroup>
		<col width="130px" />
		<col width="24%"/>
		<col width="130px" />
		<col width="24%"/>
		<col width="130px" />
		<col/>
	</colgroup>
  <TR height="25"> 
	<TH>업체명</TH>
	<TD colspan="3"><a href="javascript:corpPopup('<%=ContInfo.get("C_CORP_ID") %>');"><%= ContInfo.get("C_MEMBER_NAME")%></a></TD>   
	<TH>대표자명</TH>
	<TD><%= ContInfo.get("C_BOSS_NAME")%></TD> 	
  </TR>
  <TR height="25"> 
	<TH>주소</TH>
	<TD colspan="5"><%= ContInfo.get("C_ADDRESS")%></TD>  
  </TR>
  <TR height="25"> 
	<TH>담당부서</TH>
	<TD><%= ContInfo.get("C_DIVISION")%></TD>        
	<TH>담당자명</TH>
	<TD><%= ContInfo.get("C_USER_NAME")%></TD>          
	<TH>직급</TH>
	<TD><%= ContInfo.get("C_POSITION")%></TD>
  </TR>
  <TR height="25"> 
	<TH>담당자 연락처</TH>
	<TD><%= ContInfo.get("C_TEL_NUM")%></TD>
 	<TH class="required">담당자 HP</TH>
	<TD><%= ContInfo.get("C_HP")%></TD>
	<TH>담당자 EMAIL</TH>
	<TD><%= ContInfo.get("C_EMAIL")%></TD> 	
  </TR>  
  <TR height="25"> 
  	<!-- 사업자 등록번호 => 사업장 관리 번호(CORP_REG_NO => SUB_PLACE_NO) -->
	<TH class="required">사업장 관리 번호</TH>
	<TD><%= InputText.get("SUB_PLACE_NO", ContInfo.get("SUB_PLACE_NO"), 98, 30, "required,desc=사업장 관리 번호,persize") %></TD>
 	<TH class="required">법인 등록 번호</TH>
	<TD><%= InputText.get("BIZ_REG_NO", ContInfo.get("BIZ_REG_NO"), 98, 30, "required,desc=법인 등록 번호,persize") %></TD>
	<TH>공사기간</TH>
	<TD><%= ContInfo.get("START_WORK_DATE")%>&nbsp;&nbsp;~&nbsp;&nbsp;<%= ContInfo.get("END_WORK_DATE")%></TD> 	
  </TR>  
  <TR height="25"> 
	<TH class="required">면허명</TH>
	<TD><%= InputText.get("LCNS_NM", ContInfo.get("LCNS_NM"), 98, 30, "required,desc=면허명,persize") %></TD>
 	<TH class="required">면허 등록 번호</TH>
	<TD><%= InputText.get("LCNS_REG_NO", ContInfo.get("LCNS_REG_NO"), 98, 30, "required,desc=면허 등록 번호,persize") %></TD>
	<TH class="required">면허 취득일자</TH>
	<TD>	
		<%= InputText.get("LCNS_ACQT_DATE", ContInfo.get("LCNS_ACQT_DATE"), 10, 10, "desc=견적설명일시,readOnly,center") %>
		<IMG name="calendar_sitedescdate" id="calendar_sitedescdate" src="/img/buyer/button/bt_calender.gif" border="0" align="absmiddle" style="cursor:pointer;" onClick="JavaScript:dlgCalendar('LCNS_ACQT_DATE');">
	</TD> 	
  </TR>  
  <TR height="25"> 
	<TH>공사금액</TH>
	<TD align="right"><%= Formatter2.currency(ContInfo.get("CON_SUPPLY_AMT"), ContInfo.getInt("SOSUNUM"))%></TD>
 	<TH class="required">자재비</TH>
	<TD colspan="3"><%= InputText.get("MTIL_AMT", Formatter2.currency(ContInfo.get("MTIL_AMT"), ContInfo.getInt("SOSUNUM")), 50, 30, "required,desc=자재비,persize, right,float","float") %></TD>
  </TR>  
  <TR height="25"> 
	<TH class="required">공사장소</TH>
	<TD colspan="5"><%= InputText.get("INSUR_WORK_PLACE", ContInfo.get("INSUR_WORK_PLACE"), 98, 30, "required,desc=공사장소,persize") %></TD>
  </TR>  
  <!-- 계약정보 : 종료 -->
</table>

