<%--
  - Author(s)  : Hyung min Son
  - Date       : 2014.07.25
  - Description: 결격 사유 팝업
  --%>
  
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@page import="monfox.toolkit.snmp.agent.modules.SnmpV2Mib.SysOREntry"%>
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ include file="/jsp/work/taglib.jsp" %>
<%@ page import="kr.co.hsnc.common.sql.RowSet" %>
<%@ page import="kr.co.hsnc.common.util.ValueObject" %>
<%@ page import="com.udapsoft.waf.system.*" %>
<%@ page import="com.udapsoft.waf.common.*" %>
<%@ page import="kr.co.udapsoft.common.*" %>
<%@ page import="com.udapsoft.waf.common.ui.*" %>
<%@ page import="com.udapsoft.waf.common.ui.HTMLMaker" %>
<%@ page import="com.udapsoft.waf.common.util.StringUtils"%>
<%@ page import="com.udapsoft.waf.system.HandlerStorage" %>
<%@ page import="kr.co.udapsoft.ebid.buyer.common.file.FileManager"%>
<%@ page import="java.net.URLEncoder"%>
<jsp:useBean id="ctx" class="com.udapsoft.waf.system.context.SessionContext" scope="session" />
<%
    ctx.init(request, response);
    HandlerStorage storage = ctx.getHandlerStorage();
    ValueObject user       = ctx.getUser();
    ValueObject params     = storage.getParams();
    String event           = storage.getEvent();
    ValueObject Order = storage.getValueObject("Order");
    
	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");
	String FILE_GB =   (String) storage.get("FILE_GB");
	String DEMANDED_ID =   (String) storage.get("DEMANDED_ID");
	String DIV_PO_YN =   (String) storage.get("DIV_PO_YN");
    ValueObject file = storage.getValueObject(storage.get("FILE_GB"));
%>
<SCRIPT language="JavaScript">
	var sheet1;
	var sheet1Row;
	var sheet1PageNo = 1;
	var pageLastRowIndex = 1;
	var validationResult = false;
	var filterShow = false;
	
    function _onReady(){
		gridInit(sheet1);
		autoResize();
		sheet1.SetSumValue(5,"합      계");
		doSearchSheet();
		
		$("#btnExcelDown").click(function(){
				var params = { FileName : "견적내역상세.xls",  SheetName : "견적내역상세", SheetDesign:1 ,DownSum:false, DownCols:"MATERIAL_NAME|MATERIAL_SPEC|UNIT_KIND|QTY|UNIT_COST|ROW_SUM_AMT"
					,	TitleText : "<%=Order.get("BID_MASTER_NM")%> 견적서"
					,	UserMerge : "0,0,1,6"
					};
			sheet1.Down2Excel(params);
		});
	}
    
	function doSearchSheet(){
		$("#fevent").val("VENDOR_SHEET_SELECT");
		var url = Modular.model.PageContext.CONTEXT_ROOT + "/bid/purchase/SignBidAmtPop_sheet.screen";
		Modular.view.IBSheet7.doSearch(sheet1, url, jQuery("#form1"), 30, "");
	}
    
    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:100, 			Align:"Left",			Hidden:"True"},
			    			{Header:'자재명',				Type:"Text", 			SaveName:"MATERIAL_NAME", 			Width:100, 			Align:"Left",			Edit:false},
			    			{Header:'규격',					Type:"Text", 			SaveName:"MATERIAL_SPEC", 							Width:120, 			Align:"Left", 	Edit:false},
			    			{Header:'단위',					Type:"Text", 			SaveName:"UNIT_KIND", 					Width:50, 			Align:"Center", 	Edit:false},
			    			{Header:'수량',					Type:"Float",			SaveName:"QTY", 							Width:80, 			Align:"Right", 	Edit:false},
			    			{Header:'단가',					Type:"Float",			SaveName:"UNIT_COST", 					Width:80, 			Align:"Right",	PointCount:<%=Order.get("PointCount")%>},
			    			{Header:'금액',					Type:"AutoSum", 		SaveName:"ROW_SUM_AMT",			 	Width:80, 			Align:"Right", Edit:false,	PointCount:<%=Order.get("PointCount")%>}
		];

		init_sheet.HeaderMode = {Sort:1};
		IBS_InitSheet(sheetName, init_sheet);
		sheetName.SetDataAutoTrim(0);
		sheetName.SetEditable(false);
		setGridSize();
	}
 
 	function setGridSize() {
		sheet1.FitColWidth();
	}
 
	/**
	 *	IBSheet Event: Search End(IBSheet 데이터 조회 CallBack)
	 */
	function sheet1_OnSearchEnd(code, message) {
	    if(code == 0) {
	    	setGridSize();
				var GrowCount = sheet1.LastRow();
				//var amt = sheet1.GetCellValue(GrowCount,"ROW_SUM_AMT");
				var amt = sheet1.GetCellText(GrowCount,"ROW_SUM_AMT");
				if(amt != ""){
					$("#TOT_AMT").val(amt);
					//$("#TOT_AMT").val(formatComma(amt,"<%=Order.get("PointCount")%>"));
					//$("#TOT_AMT").val($("#TOT_AMT").val().split(/(?=(?:\d{3})+(?:\.|$))/g).join(','));
				}
		} else {
			//조회 에러 수행
			alert(message);
		}
	}
    
    function sheet1_OnSmartResize(Width, Height) { 
		sheet1.FitColWidth();
		autoResize();
	}
    
	 function numberFormat(num) {
		 var pattern = /(-?[0-9]+)([0-9]{3})/;
		 while(pattern.test(num)) {
			 num = num.replace(pattern,"$1,$2");
		 }
		 return num;
	 }
	 

	function autoResize(){
		var setheight = $("#table_a").height() - $("#table_b").height() -50;
		if(setheight < 110){
			setheight = 200;
			sheet1.SetSheetHeight(setheight);
		}
		
		//alert($("#sheettable").width());
		//sheet1.SetSheetWidth($("#sheettable").width());
	}
	/**
	 * 첨부파일 예약 함수
	 */
	function fileDown(file_id){
			var url="/common/file/FileDownloadServlet";
	 		url += "?file_id=" + file_id;
	 		
	 		window.open(url, "_fileDown", "toolbar=no, width=400, height=100, top=500, left=400, toolbar=no,directories=no,status=no,scrollbars=yes,resize=no,menubar=no,target=new")
	}
	
	//첨부파일   
	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('<%=FILE_GB%>', obj.value, document.form1.p_AttachFile, "N", file_div);
		} 
	}
	
	function doAttachFileDiv(obj) {
		 if(obj==''){
			alert("저장을 한 후 파일을 첨부할 수 있습니다.");
		}
		else if(obj != ''){ 
			viewFileListNew('<%=FILE_GB%>', obj.value, document.form1.p_AttachFile, "N", file_div);
		} 
	}
	
    document.onkeydown 		= closePopupWindow;
    //document.body.onload = _onReady;
</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="<%=VENDOR_CD%>">
<INPUT type="hidden" name="FILE_GB" value="<%=FILE_GB%>">


<TABLE class="form-table" style="margin-top:3px">
	<colgroup>
		<col width="160">
		<col/>
	</colgroup>
	<TR height="25"> 
		<TH>사업자번호</TH>
		<TD><%=StringUtils.getBizNo(Order.get("CORP_REG_NO")) %></TD>
	</TR>
	<TR height="25">     
		<TH> 업체명</TH>
		<TD><%=Order.get("CORP_KOR")%></TD>
	</TR>
	<TR height="25"> 
		<TH> 견적합계금액</TH>
		<TD><%= InputText.get("TOT_AMT", "", 50, 300, "class=input_blank,desc=견적합계금액,readOnly=white") %></TD>
	</TR>
</table>
<TABLE class="form-table" width="100%">
	<colgroup>
		<col width="43%">
		<col width="57%"/>
	</colgroup>
<tr rowspan="2"><td valign="top"  rowspan="2" >
	   		   <div align="left" id="title">
			    <ul>
			     <li>견적조건</li>
			    </ul>
			  </div> 
<TABLE class="form-table" id=table_a>
	<colgroup>
		<col width="156">
		<col/>
	</colgroup>
  <TR height="25"> 
	<TH>견적통화</TH>
	<TD colspan="2">
 <%=Order.get("CURRENCY_GB_NM")%>
	</TD>
  </TR>
  <% if("Y".equals(Order.get("PBC_INSTALL_YN"))){ %>
	<TR height="25">
		<TH>Installation</TH>
		<TD colspan="2" >
		<%=Order.get("INSTALL_YN").equals("Y") ? "included" : "not included" %>
		</TD>
	</TR>
	<%} if("Y".equals(Order.get("PBC_COMMISS_YN"))){ %>
	<TR height="25">	
		<TH>Spare parts for<br>Commissioning</TH>
		<TD colspan="2">
		<%=Order.get("COMMISS_YN").equals("Y") ? "included" : "not included" %>
		</TD>
	</TR>
	<%} if("Y".equals(Order.get("PBC_SPETOOL_YN"))){ %>
	<TR height="25">	
		<TH>Special Tool</TH>
		<TD colspan="2">
		<%=Order.get("SPETOOL_YN").equals("Y") ? "included" : "not included" %>
		</TD>
	</TR>
	<%} if("Y".equals(Order.get("PBC_TEST_YN"))){ %>
	<TR height="25">	
		<TH>Test & Inspection<br/>at Fabrication shop</TH>
		<TD colspan="2">
		<%=Order.get("TEST_YN").equals("Y") ? "included" : "not included" %>
		</TD>
	</TR>
	<%} if("Y".equals(Order.get("PBC_DOC_YN"))){ %>
	<TR height="25">	
		<TH>Documentation</TH>
		<TD colspan="2">
		<%=Order.get("DOC_YN").equals("Y") ? "included" : "not included" %>
		</TD>
	</TR>
	<%} if("Y".equals(Order.get("PBC_PACK_YN"))){ %>
	<TR height="25">	
		<TH>Packing cost</TH>
		<TD colspan="2">
		<%=Order.get("PACK_YN").equals("Y") ? "included" : "not included" %>
		</TD>
	</TR>
	<%} if("Y".equals(Order.get("PBC_LANDTRAN_YN"))){ %>
	<TR height="25">	
		<TH>Inland<br>Transportaion</TH>
		<TD colspan="2">
		<%=Order.get("LANDTRAN_YN").equals("Y") ? "included" : "not included" %>
		</TD>
	</TR>
	<%} if("Y".equals(Order.get("DELIVERY_CONDITION_YN"))){ %>
	<TR height="25">	
		<TH>Delivery Condition</TH>
		<TD colspan="2">
			<%=Order.get("DELIVERY_CONDITION_NM")%>
		</TD>
	</TR>
	<%} if("Y".equals(Order.get("PBC_FEE_YN"))){ %>
	<TR height="25">	
		<TH>Supervision fee</TH>
		<TD colspan="2">
			<%= Order.get("FEE_NOTI") %>		
		</TD>
	</TR>
	<%} if("Y".equals(Order.get("PBC_OPTION_YN"))){ %>
	<TR height="25">	
		<TH><%=Order.get("PBC_OPTION_COMMENT")%></TH>
		<TD colspan="2">
			<%= Order.get("OPTION_NOTI")%>
		</TD>
	</TR>
	<%} %>
	<TR height="25">	
		<TH>Quotation No</TH>
		<TD colspan="2"><%= Order.get("QUOT_NO") %>
		</TD>
	</TR>
	<TR height="25">	
		<TH rowspan="2">payment Condition</TH>
		<TD class="search_table_data">
		<%=Order.get("PAYCONDI_YN").equals("Y") ? "accept" : "not accept" %>
		<%if(!Order.get("CBC_FIRST_RATE").isEmpty()){%><br>선급금 : <%=Order.get("CBC_FIRST_RATE") %>% <%=Order.get("PBC_FIRST_CONDI") %> (계약금액 기준)<%} %>
		<%if(!Order.get("CPC_MID_RATE").isEmpty()){%><br>중도금 : <%=Order.get("CPC_MID_RATE") %>% <%=Order.get("PBC_MID_CONDI") %> (계약금액 기준)<%} %>
		<%if(!Order.get("PBC_REST_RATE").isEmpty()){%><br>잔 금  : <%=Order.get("PBC_REST_RATE") %>% <%=Order.get("PBC_REST_CONDI") %> (계약금액 기준)<%} %>
		</TD>
	</tr>		
	<tr>
		<TD style="vertical-align: top"><%=StringUtils.cvtHTML(Order.get("PAYCONDI_NOT_NOTI")) %></TD>
	</TR>
	<TR height="25">	
		<TH>Performance Bond</TH>
		<TD colspan="2" style="vertical-align: top"><%=Order.get("CONTFUL_RATE") %>%(계약금액 기준)
		<%=Order.get("CONTFUL_YN").equals("Y") ? "accept" : "not accept" %>
		 &nbsp&nbsp<%=StringUtils.cvtHTML(Order.get("CONTFUL_NOT_NOTI")) %>
		</TD>
	</TR>
	<TR height="25">	
		<TH>First Payment Bond</TH>
		<TD colspan="2" style="vertical-align: top">
		<%=Order.get("PBC_FRSTGUAR_RATE") %>%(계약금액 기준)
		<%=Order.get("FRSTGUAR_YN").equals("Y") ? "accept" : "not accept" %>
		 &nbsp<%=StringUtils.cvtHTML(Order.get("FRSTGUAR_NOT_NOTI")) %>
		</TD>
	</TR>
	<TR height="25">	
		<TH>Guarantee Bond</TH>
		<TD colspan="2"><%=Order.get("WARR_RATE") %>%(계약금액 기준)
		<%=Order.get("WARR_YN").equals("Y") ? "accept" : "not accept" %>
		 &nbsp&nbsp<%=StringUtils.cvtHTML(Order.get("WARR_NOT_NOTI")) %>
		</TD>
	</TR>
	<TR height="25">	
		<TH>Guarantee Period</TH>
		<TD colspan="2"><%=Order.get("PBC_DEFECT_CONDI") %> <%=Order.get("CBC_DEFECT_DAY") %><%=Order.get("CBC_DERECT_TERM_NM") %>간<br>
		<%=Order.get("DEFECT_YN").equals("Y") ? "accept" : "not accept" %>
		 &nbsp<%=StringUtils.cvtHTML(Order.get("DEFECT_NOT_NOTI")) %>
		</TD>
	</TR>
	<TR height="50">	
		<TH>OTHERS TO BE<br>CONFIRMED</TH>
		<TD colspan="2">
		 <%=StringUtils.cvtHTML(Order.get("BID_CONDI_NOTI")) %>
		</TD>
  </TR>
</TABLE>
</TD>
<TD style="padding-left:5px;" valign="top">
	<table style="width:100%;height:25px;margin-top:-6px">
		<colgroup>
			<col width="*" />
			<col width="200" />
		</colgroup>
		<tr heigth="25">
	   		<TD>
	   		   <div align="left" id="title">
			    <ul>
			     <li>견적내역(부가세별도)</li>
			    </ul>
			  </div> 
	   		</TD>
		   	<td style="text-align: right">
	       		<span class="btnSearch center" id="btnExcelDown"><a href="javascript:void(0);">Excel Down</a></span>
	   		</td>
	  	</tr>
	</table>
		<div id="sheet1_div" style="height: auto; min-height:100px;width:100%; overflow: auto;height:100%">
			<script>createIBSheet('sheet1','100%', '250px');</script>
		</div>
</TD>
</TR>
<TR>
<TD style="padding-left:5px;" valign="top" id=table_b>
	<table style="width:100%;height:25px;margin-top:-6px">
		<colgroup>
			<col width="*" />
			<col width="200" />
		</colgroup>
		<tr heigth="25">
	   		<TD>
	   		   <div align="left" id="title">
			    <ul>
			     <li>첨부파일</li>
			    </ul>
			  </div>
	   		</TD>
		   	<td style="text-align: right;">
	       		<span class="btnSearch center"><a href="/common/file/FileDownloadServlet?mode=zipDown&fileName=<%=URLEncoder.encode((Order.get("DEMANDED_TITLE") + "(" + Order.get("DEMANDED_NO") + ")" + "_" + Order.get("CORP_KOR")) , "UTF-8")%>&fileGB=<%=FILE_GB%>&ID=<%=DEMANDED_ID%>">모두저장(ZIP)</a></span>
	   		</td>
	  	</tr>
	</table>
<TABLE  class="form-table" style="margin-top:5px">
	<colgroup>
		<col width="160"/>
		<col/>
	</colgroup>
	<tr height="100">
	<th class="required">첨부파일</th>
	<td>
	   <div id="attach_file_view" class="attach_file_view">
	   <!-- 첨부 파일 화면에 바로보일때 사용 -->
	   <%=FileManager.getFileListForDiv(FILE_GB, DEMANDED_ID) %>
	   </div>
	</td>
	</tr>
</TABLE>
</TD>
</TR>
</TABLE>
</form>
