<%--
  - Author(s)  : Hyung min Son
  - Date       : 2014.07.25
  - Description: 결격 사유 팝업
  --%>
  
<%@ page contentType="text/html; charset=utf-8" %>
<%@ 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.HTMLMaker" %>
<%@ page import="com.udapsoft.waf.common.util.Formatter2"%>
<%@ page import="com.udapsoft.waf.system.HandlerStorage" %>
<%@ page import="kr.co.udapsoft.ebid.buyer.common.file.FileManager"%>
<%@ 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 user       = ctx.getUser();
    ValueObject params     = storage.getParams();
    String event           = storage.getEvent();
    ValueObject Order = storage.getValueObject("Order");
    
    
	String ROW =   (String) storage.get("ROW");
	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 SIGN_YN =   (String) storage.get("SIGN_YN"); 
	String fevent =   (String) storage.get("fevent");
    ValueObject file = storage.getValueObject(storage.get("FILE_GB"));
    if(Order.get("PointCount").isEmpty()){
    	Order.set("PointCount", storage.get("PointCount"));
    }
    String PointCount =   Order.get("PointCount");
%>

<SCRIPT language="JavaScript">
	var sheet1 = new ibsheetObject();
	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,"총  공  사  비");
		doSearchSheet(); 
	}

    function doSearchSheet(){
		$("#fevent").val("VENDOR_SHEET_SELECT");
		var url = Modular.model.PageContext.CONTEXT_ROOT + "/bid/outside/BidAmtPop_sheet.screen";
		if("Y" == "<%=SIGN_YN%>"){
			url = Modular.model.PageContext.CONTEXT_ROOT + "/bid/outside/SignBidAmtPop_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:<%=PointCount%>},
            {Header:'노무비',					Type:"AutoSum", 		SaveName:"LAB_COST", 				Width:60, 			Align:"right",		PointCount:<%=PointCount%>},
            {Header:'경비',					Type:"AutoSum", 		SaveName:"UNIT_COST", 				Width:60, 			Align:"right",		PointCount:<%=PointCount%>},
            {Header:'합계',					Type:"AutoSum", 		SaveName:"COST_SUM",				Width:60, 			Align:"right",	CalcLogic:"|MAT_COST|+|LAB_COST|+|UNIT_COST|",		PointCount:<%=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();
	}
 
 	function setGridSize() {
		sheet1.FitColWidth();
	}
 
	/**
	 *	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);
    		setGridSize();
		} 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 doResult(Objresult){
		
	}
	function autoResize(){
		sheet1.SetSheetHeight(560);
		sheet1.SetSheetWidth(650); 
	}
	/**
	 * 첨부파일 예약 함수
	 */
	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 doAttachFileDiv(obj) {
		var file_div = "bid/outside/"+"<%=BID_NO%>"+"/";
		 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="<%=fevent %>">
<INPUT type="hidden" name="VENDOR_CD" value="<%=VENDOR_CD%>">
<INPUT type="hidden" name="DEMANDED_ID" value="<%=DEMANDED_ID%>">
<INPUT type="hidden" name="BID_NO" value="<%=BID_NO%>">
<INPUT type="hidden" name="BID_DEG" value="<%=BID_DEG%>">
<INPUT type="hidden" name="FILE_GB" value="<%=FILE_GB%>">
<table cellspacing="1" cellpadding="0" width="100%">
<colgroup>
	<col width="350" />
	<col />
</colgroup>
<tr height="100%">
<td valign="top">
	<table class="form-table">
		<colgroup>
			<col width="140" />
			<col />
		</colgroup>
	<tr height="25">
	<th>사업자번호</th>
	<td><%=Order.get("VENDOR_NO")%></td>
	</tr>
	<tr height="25">
	<th>업체명</th>
	<td><%=Order.get("VENDOR_NAME")%></td>
	</tr>
	<tr height="25">
	<th>견적 총 금액</th>
	<td><%=Order.get("ESTI_TOT_AMT")%></td>
	</tr>
	<tr height="25">
	<th>견적 제출 일시</th>
	<td><%=Order.get("SIGN_DT")%></td>
	</tr>
	<tr height="100">
	<th>첨부파일</th>
	<td valign="top">
	   <div id="attach_file_view" class="attach_file_view">
	   <!-- 첨부 파일 화면에 바로보일때 사용 -->
	   <%=FileManager.getFileListForDiv(FILE_GB, DEMANDED_ID) %>
	   </div>
	</td>
	<!-- <IMG id='search_spot_button' onClick="doAttachFileDiv(document.form1.DEMANDED_ID);" src='/img/buyer/button/bt_change.gif' border='0'  align="top" align='absmiddle' alt='[Attach File]' style='cursor:pointer;'> -->
	</tr>
	</table>
</td>
<td>
<div id="sheet1_div" style="padding-left:5px;height: auto; min-height: 300px; overflow: auto;">
		<script>createIBSheet('sheet1','99%', '99%');</script>
	</div></td>
</td>
</tr>
</table>

</form>

