<%--
  - Author(s)  : Hyung min Son
  - Date       : 2014.08.11
  - Description: 제출견적보기
  --%>
  
<%@ page contentType="text/html; charset=utf-8" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.util.Date" %>
<%@ page import="com.udapsoft.waf.system.HandlerStorage" %>
<%@ page import="com.udapsoft.waf.common.ui.*" %>
<%@ page import="com.udapsoft.waf.common.util.StringUtils" %>
<%@ page import="kr.co.udapsoft.common.code.*" %>
<%@ 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 file = storage.getValueObject(Order.get("FILE_GB"));

%>
<!-- <script language="javascript" src="/js/crosscert/init.js"></script> -->
<SCRIPT language="JavaScript">
	/*예약함수*/
	var sheet1 = new ibsheetObject();
	var sheet1Row;
	var sheet1PageNo = 1;
	var pageLastRowIndex = 1;
	var validationResult = false;
	var filterShow = false;
	function _onReady(){
		gridInit(sheet1);
		autoResize();
		var info = [{StdCol:"DEPTH1" , SumCols:"7|8|9|10|11",CaptionText:"[소    계]",CaptionCol:3}];
		sheet1.ShowSubSum (info);
		sheet1.SetSumValue(3,"총  공  사  비");
		/**
		 *	Application Initialize
		 */
		 
		 $("#btn_back").click(function() {
				$("#fevent").val("FORM_SELECT");
				$("#form1").attr("action", "/portal/bid/SuppBidResult.screen");
				$("#form1").attr("target", "_self");
				$("#form1").attr("method", "post");
				$("#form1").submit();
		});
		
		jQuery("#btnExcel").click(function(){
			var params = { FileName : "견적내역(부가세별도).xls",  SheetName : "견적내역(부가세별도)", SheetDesign:1 , DownCols:"DEPTH1|DEPTH2|ITEM_NAME|UNIT_COST|NOTI" } ;
			sheet1.Down2Excel(params);
		});
		doSearchSheet();
	}

	function doSearchSheet(){
		$("#fevent").val("GET_ITEM_LIST");
		var url = Modular.model.PageContext.CONTEXT_ROOT + "/portal/bid/OutEstmWriteView_sheet.screen";
		Modular.view.IBSheet7.doSearch(sheet1, url, jQuery("#form1"), 30, "");
	}
	
	function gridInit(sheetName){
		var init_sheet = {};
		init_sheet.Cfg = {SearchMode:0 ,  MergeSheet:msHeaderOnly+msPrevColumnMerge};
		
		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:'구분',					Type:"Text", 			SaveName:"DEPTH1", 					Width:40, 			Align:"left",		Edit:false},
					{Header:'구분',					Type:"Text", 			SaveName:"ITEM_NAME", 				Width:140, 			Align:"left",	 		Edit:false},
					{Header:'No.',					Type:"Seq", 			SaveName:"NO",						Width:0, 			Align:"Center",		Hidden:"True"},
					{Header:'MATERIAL_CD',	        Type:"Text", 			SaveName:"MATERIAL_CD", 			Width:0, 			Align:"Center",		Hidden:"True"},
					{Header:'PARENT_LEVEL',	        Type:"Text", 			SaveName:"PARENT_LEVEL", 			Width:0, 			Align:"left",			Hidden:"True"},
					{Header:'수량/규격',			    Type:"Text", 			SaveName:"ITEMS", 					Width:0, 			Align:"Center", 	Hidden:"True"},
					{Header:'재료비',					Type:"AutoSum", 		SaveName:"MAT_COST", 				Width:60, 			Align:"right",		PointCount:<%=Order.get("PointCount")%>},
					{Header:'노무비',					Type:"AutoSum", 		SaveName:"LAB_COST", 				Width:60, 			Align:"right",		PointCount:<%=Order.get("PointCount")%>},
					{Header:'경비',					Type:"AutoSum", 		SaveName:"UNIT_COST", 				Width:60, 			Align:"right",		PointCount:<%=Order.get("PointCount")%>},
					{Header:'합계',					Type:"AutoSum", 		SaveName:"COST_SUM",				Width:60, 			Align:"right",	CalcLogic:"|MAT_COST|+|LAB_COST|+|UNIT_COST|",		PointCount:<%=Order.get("PointCount")%>},
					{Header:'산출근거',				Type:"Text",	 		SaveName:"BASIS_CALCU", 			Widtd:280, 			Align:"left",	 Edit:false},
					{Header:'비고',					Type:"Text", 			SaveName:"NOTI", 					Width:100, 			Align:"left"},
					{Header:'수량',					Type:"Text", 			SaveName:"QTY", 					Width:0, 			Align:"left", 	Hidden:"True"},
					{Header:'합계',					Type:"Text", 			SaveName:"ROW_SUM_AMT", 		    Width:0, 			Align:"left", 	Hidden:"True"}	    			
			];
		init_sheet.HeaderMode = {Sort:1};
		IBS_InitSheet(sheetName, init_sheet);
		sheetName.SetDataAutoTrim(0);
		sheetName.SetEditable(false);
		setGridSize();
		
	}


	/**
	 *	IBSheet Event: Search End(IBSheet 데이터 조회 CallBack)
	 */
	function sheet1_OnSearchEnd(code, message) {
		 if(code == 0) {
			 var row = sheet1.RowCount();
		    	
		    	sheet1.RowDelete(row);
		    	sheet1.RowDelete(row-2);
		    	sheet1.RowDelete(row-4);
		    	sheet1.SetMergeCell(row-3,2,1,2);//타이틀 머지
		    	sheet1.SetMergeCell(row-4,2,1,2);
		    	sheet1.SetMergeCell(row-5,2,1,2);
		    	sheet1.FitColWidth();
	    		
	    	    //크롬 문제 
	    	    if(sheet1.GetSheetWidth() > 450){
	    	    	sheet1.SetSheetWidth(450);
	    	    	sheet1.SetSheetWidth($("#sheettable").width());
	    	    	sheet1.FitColWidth();
	    	    }
		} else {
			//조회 에러 수행
			alert(message);
		}
	}
	/**
	 *	IBSheet Event: Click
	 */
	function sheet1_OnClick(Row, Col, Value, CellX, CellY, CellW, CellH) {
		//alert("Row :" + Row + "              Col : " +Col);	 
		if(Row == 1){
		//	exceldown();
		}
	 }
	
	/**
	 *	IBSheet size setting
	 */
	function setGridSize() {
		
		sheet1.FitColWidth();
	}
	
	 function numberFormat(num) {
		 var pattern = /(-?[0-9]+)([0-9]{3})/;
		 while(pattern.test(num)) {
			 num = num.replace(pattern,"$1,$2");
		 }
		 return num;
	 }
	 
	
	//첨부파일   
	function doAttachFile(obj) {
		if(obj==''){
			alert("After you have saved, you can attach a file.");
		}else if(obj != ''){ 
			viewFileListNew("<%=Order.get("FILE_GB")%>", obj.value, document.form1.p_AttachFile, "N", "bid/outside/<%=Order.get("BID_NO")%>/<%=Order.get("VENDOR_CD")%>/");
		} 
	}
	
	function doResult(resultObj) {
		try {
			if( resultObj.getRequestEvent() == "FORM_UPDATE") {
				if( resultObj.getSuccess() ) {
					alert("저장 되었습니다.");
					history.back();
				}
				else {
					dlgErrorMsg(resultObj);
				}
			}
			
			if( resultObj.getRequestEvent() == "FORM_DELETE") {
				if( resultObj.getSuccess() ) {
					alert("삭제 되었습니다.");
 					$("#btn_list").click();
				}
				else {
					dlgErrorMsg(resultObj);
				}
			}
		} catch(errorObject) {
			showErrorDlg("doResult()", errorObject);
		}
	}
	
	function sheet1_OnSmartResize(Width, Height) { 
		sheet1.FitColWidth();
		autoResize();
	}
	


	function autoResize(){
	//	var t1_height = document.getElementById("t1").scrollHeight + 10;
	//	var iframeHeight= document.body.scrollHeight - t1_height;   
		//var iframeWidth= document.body.scrollWidth;   
		sheet1.SetSheetHeight(560); 
	}
	
	function isEmptyVal( value ) {
		if(value.length == 0){
			return true;
		}
		if( value == "" ) {
			return true;
		}
		return false;
	}
</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="DEMANDED_KIND" value="<%=Order.get("DEMANDED_KIND")%>">
<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="VENDOR_CD" value="<%=Order.get("VENDOR_CD")%>">
<INPUT type='hidden' name="STATUS_CD" value="<%=Order.get("STATUS_CD")%>">
<%-- <INPUT type='hidden' name="VENDOR_CD" value="<%=user.get("CORP_ID")%>"> --%>
<INPUT type='hidden' name="FILE_GB" value="<%=Order.get("FILE_GB")%>">
<INPUT type='hidden' name="ATT_ID" value="<%=Order.get("ATT_ID")%>">
<INPUT type='hidden' name="ESTI_SIGNDATA" value="">
<INPUT type='hidden' name="sItemInfo" value="">
<INPUT type='hidden' name="signeddata" value="">

<table width="100%">
	<colgroup>
		<col width="*" />
		<col width="130" />
	</colgroup>
	<tr>
   		<th>
	   		<div align="left" id="title" >
 			  <ul><li>제출견적보기</li></ul>
			</div> 
   		</th>
   		<td align="right">
       		<span class="btnSearch center" id="btn_back"><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>

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

  <TR height="25"> 
	<TH style="text-align:left"> 입찰명</TH>
	<TD colspan="3">
	 <%=Order.get("BID_MASTER_NM")%>          
	</TD>
  </TR>
  <TR height="25">
  <TH style="text-align:left"> 견적제출기간</TH>
  <TD colspan="3"> 
		<%=Order.get("BID_FROM_DT")%> ~<%=Order.get("BID_TO_DT")%>
	</TD>
	</TR> 	
 <TR height="25"> 
	<TH style="text-align:left"> 통화구분</TH>
	<TD><%=Order.get("CURRENCY_GB_NM")%></TD>
	<TH style="text-align:left"> 공사기간</TH>
	<TD><%=Order.get("DELI_FROM_DY_NM")%> ~ <%=Order.get("DELI_TO_DY_NM")%></TD>	
  </TR>
  <TR height="25"> 
	<TH style="text-align:left"> 계약이행 보증</TD>
	<TD><% if(!Order.get("CONTFUL_RATE").isEmpty()){%><%=Order.get("CONTFUL_RATE")%>  %<%}%></TD>
	<TH style="text-align:left"> 하자보수 보증/기간</TD>
	<TD><% if(!Order.get("WARR_RATE").isEmpty()){%><%=Order.get("WARR_RATE")%>%<%}%><% if(!Order.get("CBC_DEFECT_DAY").isEmpty()){%> / &nbsp;준공일로부터 <%= Order.get("CBC_DEFECT_DAY")%> 개월<%}%></TD>	
  </TR>
    <TR height="25"> 
	<TH style="text-align:left"> 지급조건</TD>
	<TD><%=Order.get("PAY_TERMS_CD") %></TD>
	<TH style="text-align:left"> 공사장소</TH>
	<TD><%=Order.get("DELIVERY_PLACE") %></TD>	
  </TR>	
  <!-- 발주의뢰정보 : 종료 -->
</table>


<TABLE width="100%">
	<colgroup>
		<col width="40%">
		<col width="60%"/>
	</colgroup>
<tr style="height:10%"><td style="vertical-align: top;">
<div class="application-info">
	<div class="application-sub-title">
		<span class="title">견적정보</span>
	</div>
</div>
<TABLE class="form-table">
	<colgroup>
		<col width="145">
		<col/>
	</colgroup>
	<TR height="25"> 
		<TH style="text-align:left">사업자번호</TH>
		<TD><%=StringUtils.getBizNo(user.get("CORP_REG_NO")) %></TD>
	</TR>
	<TR height="25">     
		<TH style="text-align:left"> 업체명</TH>
		<TD><%=user.get("CORP_KOR")%></TD>
	</TR>
	<TR height="25"> 
		<TH style="text-align:left"> 견적합계금액</TH>
		<TD><%= InputText.get("TOT_AMT", "", 50, 300, "class=input_blank,desc=견적합계금액,readOnly=white") %></TD>
	</TR>
</table>
</TD>
<TD rowspan="4" style="padding-left:5px;vertical-align: top;">
	<table id="sheettable" style="width:100%;height:25px;">
		<colgroup>
			<col width="*" />
			<col width="130" />
		</colgroup>
		<tr heigth="25">
	   		<th>
	   		<div class="application-info">
				<div class="application-sub-title">
					<span class="title">견적내역(부가세별도)</span>
				</div>
			</div>
	   		</th>
	   		<td align="right">
	       		<span class="btnSearch center" id="btnExcel"><a href="javascript:void(0);">Excel Down</a></span>
	   		</td>
	  	</tr>
	</table>
		<div id="sheet1_div" style="height: auto; min-height: 300px;width:100%; overflow: auto;height:100%">
			<script>createIBSheet('sheet1','500px', '590px');</script>
		</div>
</TD>
</TR>
<TR style="height:500px"><TD align="top" width="*" style="vertical-align: top">
<div class="application-info">
	<div class="application-sub-title">
		<span class="title">첨부파일</span>
	</div>
</div>
	<TABLE class="form-table">
		<colgroup>
			<col width="145">
			<col/>
		</colgroup>
	  <TR height="100"> 
		<TH style="text-align:left"> 첨부파일</TD>
		<TD>
		 <TEXTAREA name="p_AttachFile" id="p_AttachFile" style="width:85%;height:80px" rows="1" class="input" readOnly><%=file.get(Order.get("FILE_GB")) %></TEXTAREA>
		                    <IMG id='search_spot_button' onClick="doAttachFile(document.form1.DEMANDED_ID);" src='/img/buyer/button/bt_change.gif' border='0'  align="top" align='absmiddle' alt='[Attach File]' style='cursor:pointer;'>
		</TD>
	  </TR>  
	</TABLE>
</TD>
</TR>
</TABLE>
</form>
