<%--
  - Author(s)  : Hyung min Son
  - Date       : 2014.06.30
  - 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.udapsoft.common.code.*" %>
<%@ page import="com.udapsoft.waf.common.util.StringUtils"%>
<%@ page import="kr.co.hsnc.common.util.*"%>
<%@ page import="kr.co.hsnc.common.sql.*" %>
<%@ 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 Order = storage.getValueObject("Order");
    ValueObject filein = storage.getValueObject(Order.get("DOC_ETC_IN"));
    ValueObject fileout = storage.getValueObject(Order.get("DOC_ETC_OUT"));
%>
<SCRIPT language="JavaScript">
	/*예약함수*/
	var sheet1 = new ibsheetObject();
	var sheet1Row;
	var sheet1PageNo = 1;
	var pageLastRowIndex = 1;
	var validationResult = false;
	var filterShow = false;
	
	var must_msg = "(은)는 필수 입력 항목입니다."; 
	function _onReady(){
		$("#SITE_ATTEND_YN option:eq(2)").remove();   // selectbox 에 NULL 값 제거
		$("#SITE_ATTEND_TABLE").hide();//불참 사유 숨김.
		$("#SITE_ATTEND_DIV").hide();//불참 사유 숨김.
		gridInit(sheet1);
		
		 $("#btn_list").click(function() {
				$("#fevent").val("");
				$("#form1").attr("action", "/portal/bid/SiteExplanList.screen");
				$("#form1").attr("target", "_self");
				$("#form1").attr("method", "post");
				$("#form1").submit();
		});

		 $("#btn_Save").click(function() {
			 var msg = "저장 하시겠습니까?";
			 if($("#SITE_ATTEND_YN").val() == ""){
				 alert("견적설명회 참석의사를 선택하세요");
				 $("#SITE_ATTEND_YN").focus();
				 return;
			 }else if($("#SITE_ATTEND_YN").val() == "Y"){
				 msg = "견적설명회에 참석하시겠습니까?";	 
			 }else if($("#SITE_ATTEND_YN").val() == "N"){
				 msg = "견적설명회에 불참하시겠습니까?";	 
				 if($("#SITE_ATTEND_REASON").val().length == 0){
					 alert("견적설명회 불참사유는 필수입니다.");
					 $("#SITE_ATTEND_REASON").focus();
					 return;
				 }
			 }
			 
			 if(confirm(msg)){
				var f = document.form1;
				$("#fevent").val("FORM_UPDATE");
				submitXmlRequest("/portal/bid/SiteExplan_form.screen", "FORM_UPDATE", f);
			 }
		});
		 $("#SITE_ATTEND_YN").val("<%=Order.get("SITE_ATTEND_YN")%>");
		 var statusCd = "<%=Order.get("STATUS_CD")%>";
		 if(statusCd != "03"){
			 $("#SITE_ATTEND_YN").attr("disabled",true);
			 $("#btn_Save").hide();
		 }
		 $("#SITE_ATTEND_YN").change(function() {
			 if($("#SITE_ATTEND_YN").val() == "N"){
					$("#SITE_ATTEND_TABLE").show();//불참 사유 숨김.
					$("#SITE_ATTEND_DIV").show();//불참 사유 숨김.
			 }else{
					$("#SITE_ATTEND_TABLE").hide();//불참 사유 숨김.
					$("#SITE_ATTEND_DIV").hide();//불참 사유 숨김.
			 }
		 });
		 
		 if("<%=Order.get("PBC_DEFECT_CONDI2")%>"!=""||"<%=Order.get("CBC_DEFECT_DAY2")%>"!=""||"<%=Order.get("CBC_DERECT_TERM_CD2")%>"!=""){
				$("#addGuar").attr("checked", true);
				$(".checkAdd").show();
		 }
		 
		 $("#SITE_ATTEND_YN").change();
		 
		 doSearchSheetitem();
	}

	/**
	 *	IBSheet object initialize
	 */
	function gridInit(sheetName){
		var init_sheet = {};
		init_sheet.Cfg = {SearchMode:2, Page:30};
		init_sheet.Cols = [
			       			{Header:'Del',					Type:"DelCheck",		SaveName:"DEL_CHECK", 					Width:0, 			Align:"Center",	Hidden:"True"},
			    			{Header:'Status',				Type:"Status", 		SaveName:"STATUS", 						Width:0, 			Align:"Center",	Hidden:"True"},
			    			{Header:'No.',					Type:"Seq", 			SaveName:"NO",								Width:0, 			Align:"Center",	Hidden:"True"},
			    			{Header:'자재코드',				Type:"Text", 			SaveName:"MATERIAL_CD", 				Width:60, 			Align:"Center"},
			    			{Header:'자재명',				Type:"Text", 			SaveName:"MATERIAL_NAME", 			Width:220, 			Align:"Left"},
			    			{Header:'규격',					Type:"Text", 			SaveName:"STD", 							Width:70, 			Align:"Left"},
			    			{Header:'단위',					Type:"Text", 			SaveName:"UNIT_KIND", 					Width:40, 			Align:"Center"},
			    			{Header:'투입요청일',			Type:"Text", 			SaveName:"REQUEST_DATE", 				Width:50, 			Align:"Center"},
			    			{Header:'견적의뢰수량',			Type:"Float", 			SaveName:"DEMANDED_QTY", 			Width:50, 			Align:"Right"}
			];
		init_sheet.HeaderMode = {Sort:1};
		IBS_InitSheet(sheetName, init_sheet);
		sheetName.SetDataAutoTrim(0);
		sheetName.SetEditable(false);
		setGridSize();
	}
	
	//첨부파일   
	function doAttachFile(obj,No) {
		var file_div = "bid/purchase/"+"<%=Order.get("BID_NO")%>"+"/";
		 if(obj==''){
			alert("After you have saved, you can attach a file.");
		}
		else if(obj != ''){ 
				viewFileListNew("<%=Order.get("DOC_ETC_OUT")%>", obj.value, document.form1.p_AttachFile2, "N", file_div);
		}
	}
	
	/**
	 *	IBSheet Event: Search End(IBSheet 데이터 조회 CallBack)
	 */
	function sheet1_OnSearchEnd(code, message) {
	    if(code == 0) {
	    	setGridSize();
	    	sheet1.FitColWidth();
	    	var rowcnt = sheet1.RowCount();
			if(rowcnt> 0){
				for(var r=0; r < rowcnt; r++)
				{
					if(sheet1.GetCellValue(r+1,"SITE_ATTEND_YN") == "N"){	
						sheet1.SetCellFont("FontColor", r+1, "SITE_ATTEND_YN", r+1, "SITE_ATTEND_YN", "blue");
//						sheet1.SetColCondProperty("SITE_ATTEND_YN","%d='N'",{FontColorT:"blue",CursorT:"Pointer"});
					}
					<%if("Y".equals(Order.get("DIV_PO_YN"))){ %>
						sheet1.SetCellValue(r+1,"DEMANDED_QTY",1);	
					<%}%>
				}
			}
		} else {
			//조회 에러 수행
			alert(message);
		}
	}
	
	function doSearchSheetitem(){
		$("#fevent").val("GET_ITEM_LIST");
		var url = Modular.model.PageContext.CONTEXT_ROOT + "/portal/bid/QuotRequest_sheet.screen";
		Modular.view.IBSheet7.doSearch(sheet1, url, jQuery("#form1"), 30, "");
	}

	/**
	 *	IBSheet size setting
	 */
	function setGridSize() {
		sheet1.FitColWidth();
	}
	
	function sheet1_OnSmartResize(Width, Height) { 
		sheet1.FitColWidth();
		autoResize();
	}

	function autoResize(){	}	
	
	function doResult(resultObj) {
		try {
			if( resultObj.getRequestEvent() == "FORM_UPDATE") {
				if( resultObj.getSuccess() ) {
					alert("견적설명회 참석의사가 저장되었습니다.");
					$("#fevent").val("FORM_SELECT");
					$("#form1").attr("action", "/portal/bid/SiteExplanPurchase.screen");
					$("#form1").attr("target", "_self");
					$("#form1").attr("method", "post");
					$("#form1").submit();
				}
				else {
					dlgErrorMsg(resultObj);
				}
			}
		} catch(errorObject) {
			showErrorDlg("doResult()", errorObject);
		}
	}
</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="DEMANDED_ID" value="<%=Order.get("DEMANDED_ID")%>">
<INPUT type='hidden' name="BID_NO" value="<%=Order.get("BID_NO")%>">
<INPUT type='hidden' name="BID_DEG" value="<%=Order.get("BID_DEG")%>">
<INPUT type='hidden' name="STATUS_CD" value="<%=Order.get("STATUS_CD")%>">
<INPUT type="hidden" name="VENDOR_CD" value="<%=user.get("CORP_ID")%>">

<table width="100%">
	<colgroup>
		<col width="500" />
		<col width="*" />
	</colgroup>
	<tr>
   		<th>
	   		<div align="left" id="title" >
 			  <ul><li>구매_견적설명회 상세 <font style="font-size:11px">(<%=Order.get("STATUS_NM")%>)</font></li></ul>
			</div> 
   		</th>
   		<td align="right">
   			<span class="btnSearch center" id="btn_Save"><a href="javascript:void(0);">저장</a></span>
       		<span class="btnSearch center" id="btn_list"><a href="javascript:void(0);">목록</a></span>
   		</td>
  	</tr>
</table>
<!-- 발주의뢰정보 : 시작 -->
<div class="application-info magT15" id=SITE_ATTEND_DIV>
	<div class="application-sub-title">
		<span class="title">견적설명회 불참사유</span>
	</div>
</div>
<TABLE class="form-table" id=SITE_ATTEND_TABLE>
	<colgroup>
		<col width="160"/>
		<col/>
	</colgroup>
  <TR height="25"> 
    <TH style="text-align:left">불참사유</TH>
	<TD><TEXTAREA name="SITE_ATTEND_REASON" id="SITE_ATTEND_REASON" style="width:99%;height:50px" rows="1" class="input" ><%=Order.get("SITE_ATTEND_REASON")%></TEXTAREA></TD>
  </TR>
 </TABLE>

<!-- 발주의뢰정보 : 시작 -->
<div class="application-info magT15">
	<div class="application-sub-title">
		<span class="title">발주의뢰정보</span>
	</div>
</div>

<TABLE class="form-table">
	<colgroup>
		<col width="160"/>
		<col width="160"/>
		<col width="29%"/>
		<col width="160"/>
		<col/>
	</colgroup>
  <TR height="25"> 
    <TH style="text-align:left"> 입찰번호-차수</TH>
	<TD colspan="2"><%=Order.get("bid_no") %> - <%=Order.get("bid_deg") %></TD>
	<TH style="text-align:left"> 온라인입찰여부</TH>
	<TD><%=Order.get("ONBID_YN_NM")%></TD>
  </TR>

  <TR height="25"> 
	<TH style="text-align:left">입찰명</TD>
	<TD colspan="2"><%=Order.get("BID_MASTER_NM")%></TD>
	<TH style="text-align:left">단가계약여부</TD>
	<TD colspan="2"><%=Order.get("DIV_PO_YN").equals("Y") ? "예" : "아니오" %></TD>
  </TR>

<!-- 2020.06.16 협력업체포탈 정보 조회불가토록 변경 요청 -->    
   <TR height="25"> 
	<%--<TH style="text-align:left"> 경쟁방법</TH>
	<TD colspan="2"><%=Order.get("CMPT_NM") %></TD>--%>
	<TH style="text-align:left"> 낙찰자선정방법</TH>
	<TD colspan="4"><%= Order.get("SUCC_NM") %></TD> 	
  </TR>  
  	
  <!-- 발주의뢰정보 : 종료 -->
</table>

<div class="application-info magT15">
	<div class="application-sub-title">
		<span class="title">입찰진행</span>
	</div>
</div>

<TABLE class="form-table">
	<colgroup>
		<col width="160"/>
		<col width="160"/>
		<col width="29%"/>
		<col width="160"/>
		<col/>
	</colgroup>
  <TR height="25"> 
    <TH style="text-align:left">공고일자</TH>
	<TD colspan="4"><%=Order.get("NOTI_DY_NM") %></TD>
  </TR>


  <TR height="25"> 
	<TH rowspan="4" style="text-align:left"> 견적설명회 정보</TH>
	<TH style="text-align:left"> 여부</TH>
	<TD><%=Order.get("SITEDESC_FLAG_NM")%></TD>
	<TH style="text-align:left"> 담당자</TH>
	<TD><%=Order.get("SITEDESCCHRGPRSNNM")%></TD>	
  </TR>
  
  <TR height="25"> 
	<TH style="text-align:left"> 담당자 전화번호</TH>
	<TD><%=Order.get("SITEDESCTELNO")%></TD>
	<TH style="text-align:left"> 일시</TH>
	<TD><%=Order.get("SITEDESCDATE_NM")%></TD>		
  </TR> 	
  
    <TR height="25"> 
	<TH style="text-align:left">담당자 E-Mail</TH>
	<TD><%=Order.get("SITEDESCEMAIL")%></TD>
	<TH style="text-align:left">장소</TH>
	<TD><%=Order.get("SITEDESCPLACE")%></TD>		
  </TR> 
   <TR height="25">
   	<TH style="background:#ffe1b5;text-align:left">참석의사</TD>
	<TD> <%=CommCodeManager.getSelectCodeList("BID_SUPP_SITEPARTI","SITE_ATTEND_YN","height=18;","<option value=''>--선택--</option>", Order.get("SITE_ATTEND_YN")) %>
	</TD> 
	
	  <%
  	String		sitedescYn	=	"";
  	if(Order.get("SITEDESC_YN").equals("Y"))
  	{
  		sitedescYn	=	"<font color='red'>"+Order.get("SITEDESC_YN_NM")+"</font>";
  	}
  	else
  	{
  		sitedescYn	=	"<font color='blue'>"+Order.get("SITEDESC_YN_NM")+"</font>";
  	}
  %>
	<TH style="background:#ffe1b5;text-align:left">참여상태</TD>
	<TD><B><%=sitedescYn%></B></TD>		
  </TR> 
  
  <TR height="25"> 
	<TH rowspan="2" style="text-align:left">견적 의뢰</TH>
	<TH style="text-align:left"> 견적제출기간</TH>
	<TD colspan="3"><%=Order.get("BID_FROM_DT_NM")%> ~<%=Order.get("BID_TO_DT_NM")%></TD>
  </TR>
  
  <TR height="25"> 
	<TH style="text-align:left">구매담당자</TH>
	<TD><%=Order.get("PUREMPNM")%></TD>
	<TH style="text-align:left">구매담당자 전화번호</TH>
	<TD><%=Order.get("PO_EMPNM")%></TD>		
  </TR> 	
  </TR> 
  
  <TR height="25"> 
	<TH style="text-align:left">기술검토(TBE)</TH>
	<TH style="text-align:left">TBE 여부</TH>
	<TD><%=Order.get("TBE_FLAG").equals("Y") ? "예" : "아니오" %></TD>
	<TH style="text-align:left"> TBE 일자</TH>
	<TD><%=Order.get("SUPP_REQ_DY_NM")%></TD>	
  </TR>
  <!-- 발주의뢰정보 : 종료 -->
</table>

<div class="application-info magT15">
	<div class="application-sub-title">
		<span class="title">입찰조건</span>
	</div>
</div>

<TABLE class="form-table">
	<colgroup>
		<col width="160"/>
		<col width="20%">
		<col width="160"/>
		<col width="20%">
		<col width="160"/>
		<col/>
	</colgroup>
  <TR height="25"> 
	<TH style="text-align:left">통화구분</TH>
	<TD colspan="5"><%=Order.get("CURRENCY_GB_NM") %> &nbsp&nbsp  
		<%=Order.get("CURRENCY_GB_YN").equals("Y") ? "[업체변경가능]" : "[업체변경불가능]" %>
	</TD>
  </TR>
  <TR height="25"> 
	<TH style="text-align:left">Installation</TH><!-- 설치비 포함여부 -->
	<TD><%=Order.get("PBC_INSTALL_YN").equals("Y") ? "업체 견적내용 반영" : "업체 견적내용 미반영" %></TD>
	<TH style="text-align:left">Spare Parts for Commissionig</TH><!-- 시운전 포함여부 -->
	<TD><%=Order.get("PBC_COMMISS_YN").equals("Y") ? "업체 견적내용 반영" : "업체 견적내용 미반영" %></TD>
	<TH style="text-align:left">Special Tool</TH><!-- 설치비 특별공구 포함여부 -->
	<TD><%=Order.get("PBC_SPETOOL_YN").equals("Y") ? "업체 견적내용 반영" : "업체 견적내용 미반영" %></TD>	
  </TR>
  <TR height="25"> 
	<TH style="text-align:left">Test & Inspection at Fabrication shop</TH><!-- 샾(공장) 검사비용 포함여부 -->
	<TD><%=Order.get("PBC_TEST_YN").equals("Y") ? "업체 견적내용 반영" : "업체 견적내용 미반영" %></TD>
	<TH style="text-align:left">Documentation</TH><!-- vendor print  (무조건 포함)  삭제? -->
	<TD><%=Order.get("PBC_DOC_YN").equals("Y") ? "업체 견적내용 반영" : "업체 견적내용 미반영" %></TD>
	<TH style="text-align:left">Packing cost</TH><!-- 포장비용 포함여부 -->
	<TD><%=Order.get("PBC_PACK_YN").equals("Y") ? "업체 견적내용 반영" : "업체 견적내용 미반영" %></TD>	
  </TR>
  <TR height="25"> 
	<TH style="text-align:left">Inland Transportaion</TH><!-- 내륙운송비 -->
	<TD><%=Order.get("PBC_LANDTRAN_YN").equals("Y") ? "업체 견적내용 반영" : "업체 견적내용 미반영" %></TD>
	<TH style="text-align:left">Delivery Condition</TH><!-- 인도조건 (현장도착도, 현장상차도,현장설치도, 설치시운전도) -->
	<TD colspan="3">
	  <%if(!Order.get("DELIVERY_CONDITION_NM").isEmpty()){ %><%=Order.get("DELIVERY_CONDITION_NM") %>&nbsp&nbsp  <%}%><%=Order.get("DELIVERY_CONDITION_YN").equals("Y") ? "[업체변경가능]" : "[업체 변경 불가능]" %></TD>
  </TR>
   <TR height="25"> 
	<TH style="text-align:left">OPTIONAL PRICE</TH><!-- 현장감독관 일당   &     기타일당 내역 -->
	<TD colspan="5">A. Supervision fee &nbsp <%=Order.get("PBC_FEE_YN").equals("Y") ? "업체 견적내용 반영" : "업체 견적내용 미반영" %>
	    &nbsp&nbsp  <%if(!Order.get("PBC_OPTION_COMMENT").isEmpty()){ %>B. <%= Order.get("PBC_OPTION_COMMENT")%> &nbsp<%=Order.get("PBC_OPTION_YN").equals("Y") ? "업체 견적내용 반영" : "업체 견적내용 미반영" %><%}%></TD>
  </TR>
  <TR height="25"> 
	<TH style="text-align:left">Liquidated Damages</TH><!-- 지체상금 fix -->
	<TD colspan="5"><%if(!Order.get("CBC_DAMAGE_RATE").isEmpty()){ %><%= Order.get("CBC_DAMAGE_RATE")%>%  <%=Order.get("CBC_DAMAGE_NM") %>,<%}%>
	                        <%if(!Order.get("CBC_DAMAGE_MAXRATE").isEmpty()){ %> Max <%= Order.get("CBC_DAMAGE_MAXRATE")%>%<%}%></TD>
  </TR>
  <TR height="25"> 
	<TH style="text-align:left">선급금</TH>
	<TD><%if(!Order.get("CBC_FIRST_RATE").isEmpty()){ %><%=Order.get("CBC_FIRST_RATE") %>% <%}%><%= Order.get("PBC_FIRST_CONDI")%></TD>
	<TH style="text-align:left">중도금</TH>
	<TD><%if(!Order.get("CPC_MID_RATE").isEmpty()){ %><%= Order.get("CPC_MID_RATE")%>% <%}%><%=Order.get("PBC_MID_CONDI")%></TD>
	<TH style="text-align:left">잔금</TH>
	<TD><%if(!Order.get("PBC_REST_RATE").isEmpty()){ %><%= Order.get("PBC_REST_RATE") %>% <%}%><%=Order.get("PBC_REST_CONDI")%></TD>	
  </TR>
  <TR height="25"> 
	<TH style="text-align:left">First Payment Bond</TH><!-- 선급금이행증권(yes, no) -->
	<TD><%if(!Order.get("PBC_FRSTGUAR_RATE").isEmpty()){ %><%= Order.get("PBC_FRSTGUAR_RATE") %>% <%}%><%= Order.get("PBC_FRSTGUAR_CONDI")%></TD>
	<TH style="text-align:left">Performance Bond</TH><!-- 계약이행증권(yes, no) -->
	<TD><%if(!Order.get("CONTFUL_RATE").isEmpty()){ %><%= Order.get("CONTFUL_RATE") %>%<%}%> <%=Order.get("CONTFUL_CONDI") %></TD>
	<TH style="text-align:left">Guarantee Bond</TH><!-- 하자이행증권(yes, no) -->
	<TD><%if(!Order.get("WARR_RATE").isEmpty()){ %><%= Order.get("WARR_RATE") %>%<%}%> <%= Order.get("WARR_CONDI")%></TD>	
  </TR>  
  <TR height="25"> 
	<TH style="text-align:left">Guarantee Period</TH><!-- 하자보수기간 -->
	<TD colspan="3"><%=Order.get("PBC_DEFECT_CONDI") %> <%=Order.get("CBC_DEFECT_DAY") %>  
	<%=Order.get("CBC_DERECT_TERM_NM") %>간
	<input type="checkbox" id="addGuar" style="margin-top:2px; display:none;">
	<span class="checkAdd" style="display:none;">&nbsp;or&nbsp;
	<%=Order.get("PBC_DEFECT_CONDI2") %> <%=Order.get("CBC_DEFECT_DAY2")%>  
	<%if(Order.get("CBC_DERECT_TERM_CD2").equals("01")){%>
		<span>일 간 중 선도래일</span>
	<%}else if(Order.get("CBC_DERECT_TERM_CD2").equals("02")){%>
		<span>개월 간 중 선도래일</span>
	<%} %>
	</span>
	</TD>
	<TH style="text-align:left">Delivery Period</TH><!-- 납기일 fix -->
	<TD><%if(!Order.get("DELI_FROM_DY").isEmpty() || !Order.get("DELI_TO_DY").isEmpty()){ %>
		<%=Order.get("DELI_FROM_DY_NM") %> ~ 
		<%= Order.get("DELI_TO_DY_NM") %><%}%>
	</TD>
  </TR>  
</TABLE>

<TABLE class="form-table" style="margin-top:5px">
	<colgroup>
		<col width="160"/>
		<col/>
	</colgroup>
  <TR height="25"> 
	<TH style="text-align:left">특이사항</TH>
	<TD >
	 <%=StringUtils.cvtHTML(Order.get("OUTER_REMARKS"))%>   
	</TD>
  </TR>
  <TR height="100"> 
	<TH style="text-align:left">첨부파일</TH>
	<TD>
	<TEXTAREA name="p_AttachFile2" id="p_AttachFile2" style="width:85%;height:80px" rows="1" class="input" readOnly><%=fileout.get(Order.get("DOC_ETC_OUT")) %></TEXTAREA>
    <IMG id='search_spot_button' onClick="doAttachFile(document.form1.DEMANDED_ID,2);" src='/img/buyer/button/bt_change.gif' border='0'  align="top" align='absmiddle' alt='[Attach File]' style='cursor:pointer;'>
	</TD>
  </TR>  
</TABLE>

<div class="application-info magT15">
	<div class="application-sub-title">
		<span class="title">견적의뢰 내역</span>
	</div>
</div>
<div id="sheet1_div" style="height:auto; min-height: 200px; overflow: auto;">
	<script>createIBSheet('sheet1','100%', '300px');</script>
</div>

</form>
