<%--
  - Author(s)  : Hyung min Son
  - Date       : 2014.07.29
  - Description: 입찰 포기
  --%>

<%@page import="monfox.toolkit.snmp.agent.modules.SnmpV2Mib.SysOREntry"%>
<%@ page contentType="text/html; charset=utf-8" %>
<%@ page import="kr.co.udapsoft.common.*" %>
<%@ page import="com.udapsoft.waf.system.*" %>
<%@ page import="com.udapsoft.waf.common.*" %>
<%@ page import="com.udapsoft.waf.common.ui.HTMLMaker" %>
<%@ page import="com.udapsoft.waf.system.HandlerStorage" %>
<%@ page import="kr.co.hsnc.common.util.*"%>
<%@ page import="kr.co.hsnc.common.util.ValueObject" %>
<%@ page import="kr.co.hsnc.common.sql.*" %>
<%@ page import="kr.co.hsnc.common.sql.RowSet" %>
<%@ page import="kr.co.hsnc.common.sql.util.*" %>
<%@ page import="java.text.SimpleDateFormat"%>

<%-- <%@ 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 = ctx.getUser();
	String VENDOR_CD =   (String) storage.get("VENDOR_CD");
	String BID_NO =   (String) storage.get("BID_NO");
	String BID_DEG =   (String) storage.get("BID_DEG");
	String pop_win_id =   (String) storage.get("pop_win_id");
	SimpleDateFormat sd = new SimpleDateFormat("yyyyMMdd");
	String nowTime = sd.format(new Date());
%>
<%@ page contentType="text/html; charset=utf-8" %>
<SCRIPT language="JavaScript">

	function doPageInit() {
		
	}
	
	function doClose()
	{
		returnValue = null;
     	parent.PopClose("<%=pop_win_id%>",returnValue);
	}

	function giveup(){
		if($("#RNNC_REASON").val().length > 0){
			if(confirm("입찰을 포기 하시겠습니까?")){
				replace();
				SignData();
// 				if(SignData()){
// 					var f = document.form1;
// 					submitXmlRequest("/portal/bid/BidGiveupPop_form.screen", "BIDGIVEUP_SAVE", f);
// 				}
			}
		}else{
			alert("포기사유는 필수 입니다.");
		}
	}
	
	function replace(){
		var content = $("#RNNC_REASON").val();
		content = content.replace(/\r\n/g, '<br>');
		content = content.replace(/\n/g, '<br>');
		content = content.replace(/\r/g, '<br>');
		$("#RNNCREASON").val(content);
	}
	

	function doResult(resultObj) {
		try {
			if( resultObj.getRequestEvent() == "BIDGIVEUP_SAVE") {
				if( resultObj.getSuccess() ) {
					returnValue = new Array(0,"포기 되었습니다.");
					parent.PopClose("<%=pop_win_id%>",returnValue);
				}
				else {
					dlgErrorMsg(resultObj);
				}
			//	document.form1.isSubmit = false;
			}
		}
		catch(errorObject) {
			showErrorDlg("doResult()", errorObject);
		}
	}
</SCRIPT>
<SCRIPT LANGUAGE="JavaScript">
<!--

function doSetPop(signeddata){
	$("#signeddata").val(signeddata);
	
	var f = document.form1;
	submitXmlRequest("/portal/bid/BidGiveupPop_form.screen", "BIDGIVEUP_SAVE", f);
}

function SignData()
{
	
	var VendorCd = "<%=user.get("CORP_REG_NO")%>";
	var sColumDelimiter = "┃";
	var sContHash= $('#BID_NO').val()	+sColumDelimiter
				 + $('#BID_DEG').val()	+sColumDelimiter
				 + VendorCd				+sColumDelimiter;
	
	 window.parent.doSignData(VendorCd, sContHash);
	 
	 
	
/* 	unisign.SignDataNVerifyVID( sContHash, null, VendorCd, function( resultObject ) {
		if( !resultObject || resultObject.resultCode != 0 ){
			if( resultObject.resultCode == '14208'){
				alert("주민번호/사업자번호를 확인할 수 없는 인증서입니다.");
			} else if( resultObject.resultCode == '999'){
				alert("사용자 DN 선택이 취소 되었습니다.");
			} else {
				alert( resultObject.resultMessage);
			}
			return false;
		}
		
		var signeddata = resultObject.signedData;
// 		var userdn = resultObject.certAttrs.subjectName;
		
		$("#signeddata").val(signeddata);
		return true;
	}); */
	 
}

//-->
</SCRIPT>

<FORM name="form1" method="post">
<TABLE  width="580px">
<INPUT type="hidden" name="BID_NO" value="<%=BID_NO%>">
<INPUT type="hidden" name="BID_DEG" value="<%=BID_DEG%>">
<INPUT type="hidden" name="fevent" id="fevent" value="">
<INPUT type="hidden" name="RNNCREASON" id="RNNCREASON" value="">
<INPUT type="hidden" name="signeddata" id="signeddata" value="">
<input type="hidden" name="hdn_cur_ymd"	value="<%=nowTime%>">
  <TR height="2"><TD colspan="2"></TD></TR>
  <TR height="25">
    <TD>
		<table  id="t1" width="100%" border="0" cellspacing="0" cellpadding="0" class="ftit_table">
				<colgroup>
					<col width="*" />
					<col width="150" />
				</colgroup>
			<tr>
			   	<th>
			   </th>
			   <td align="right">
					<span class="btnSearch center"><a href="javascript:giveup();">입찰포기</a></span>
			   </td>
		   	</tr>
		   	</table>
</TD>
  </TR>
</TABLE>
<!-- 버튼 영역 : 시작 -->

<TABLE class="form-table">
  <TR height="100"> 
    <TH width="15%" class="required">포기사유</TH>
	<TD width="35%" class="search_table_data" > 
	 <textarea name="RNNC_REASON" id="RNNC_REASON" style="width:98%; height:140px; overflow-y:auto" maxlength="1000" class="input byteChk ctrlTarget"></textarea>
    </TD>
  </TR>
</TABLE>

</FORM>

