<%--
  - FileName   : BidOpenList.jsp
  - Author(s)  : Hyung min Son
  - Date       : 2014.07.14
  -
  - 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.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();
%>
<SCRIPT language="JavaScript">
document.body.onresize = addEvent( document.body.onresize, "autoResize()");
	/*예약함수*/
	var sheet1 = new ibsheetObject();
	var sheet1Row;
	var sheet1PageNo = 1;
	var pageLastRowIndex = 1;
	var validationResult = false;
	var filterShow = false;
	
	function _onReady(){
		/**
		 *	IBSheet object initialize
		 */
		gridInit(sheet1);
		
		autoResize();
		/**
		 *	Application Initialize
		 */
		$("#btnSearch").click(function() {
			jQuery("#fevent").val("SHEET_SELECT");
			var url = Modular.model.PageContext.CONTEXT_ROOT + "/bid/purchase/BidOpenList_sheet.screen";
			Modular.view.IBSheet7.doSearch(sheet1, url, jQuery("#form1"), 30, "");
		});
		
		/*
		현장 팝업
		*/
		$("#btn_dept").click(function() {
			PopsearchSite("");
		});
		$("#p_dept_nm").keydown(function (event){var keycode = (event.keyCode ? event.keyCode : event.which);	if(keycode == 8||keycode == 46){$("#p_dept_cd").val("");$("#p_dept_nm").val("");}});
		$("#P_BID_MASTER_NM").keydown(function (event){var keycode = (event.keyCode ? event.keyCode : event.which);if(keycode == 13)$("#btnSearch").click();});
		
		$("#btnSearch").click();
	}
	
	/**
	 *	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:50, 				Align:"Center",		Hidden:"True"},
		    			{Header:'Status',							Type:"Status", 		SaveName:"STATUS", 					Width:0, 				Align:"Center",		Hidden:"True"},
		    			{Header:'No.',								Type:"Seq", 			SaveName:"NO",							Width:40, 				Align:"Center",		Hidden:"True"},
		    			{Header:'입찰번호',							Type:"Text", 			SaveName:"BID_NO", 					Width:120,				Align:"Center"},
		    			{Header:'차수',								Type:"Text", 			SaveName:"BID_DEG", 					Width:30,				Align:"Center"},
		    			{Header:'현장코드',							Type:"Text", 			SaveName:"DEPT_CD", 					Width:120, 				Align:"Left",			Hidden:"True"},
		    			{Header:'현장',								Type:"Text", 			SaveName:"DEPT_NM", 					Width:150, 				Align:"Left"},
		    			{Header:'☞입찰공고명',						Type:"Text",	 		SaveName:"BID_MASTER_NM", 		Width:150, 				Align:"Left",			Cursor:"pointer"},
		    			{Header:'견적제출마감일시',					Type:"Text", 			SaveName:"BID_TO_DT", 				Width:100, 				Align:"Center"},
		    			{Header:'개찰일시',							Type:"Text", 			SaveName:"OPEN_DT", 					Width:100, 				Align:"Center"},
		    			{Header:'개찰자',							Type:"Text", 			SaveName:"OPEN_EMPNM", 			Width:100, 				Align:"Center"},
		    			{Header:'DEMANDED_ID',				Type:"Text", 			SaveName:"DEMANDED_ID", 			Width:100, 				Align:"Center",		Hidden:"True"},
		    			{Header:'개찰자ID',							Type:"Text", 			SaveName:"OPEN_EMPID", 				Width:100, 				Align:"Center",		Hidden:"True"},
		    			{Header:'POSTPONE_REASON',		Type:"Text", 			SaveName:"POSTPONE_REASON", 	Width:100, 				Align:"Center",		Hidden:"True"}
		    			
		];

		init_sheet.HeaderMode = {Sort:1};
		IBS_InitSheet(sheetName, init_sheet);
		sheetName.SetDataAutoTrim(0);
		sheetName.SetEditable(false);
		sheetName.SetActionMenu("ExcelDown");
		setGridSize();
	}

	function sheet1_OnSelectMenu(Text, Code) {
		  // text 또는 code값으로 Action수행
		switch(Text) {
	         case "ExcelDown":
	        	sheetExcelDown(sheet1,$('li').html());
	            break; 
		}
	}


	function searchSiteClose(result) {
		if( result == null ){
			$("#p_dept_nm").val("");
			$("#p_dept_cd").val("");
		}else{
			$("#p_dept_nm").val(result[1]);
			$("#p_dept_cd").val(result[0]);
		}
		setTimeout(function(){fLayerPopClose('_searchSite');	},100);
	}
	/**
	 *	IBSheet Event: Search End(IBSheet 데이터 조회 CallBack)
	 */
	function sheet1_OnSearchEnd(code, message) {
	    if(code == 0) {
	    	setGridSize();
	    	sheet1.SetColFontColor("BID_MASTER_NM", "#0000ff");
		} else {
			//조회 에러 수행
			alert(message);
		}
	}
	
	/**
	 *	IBSheet size setting
	 */
	function setGridSize() {
		sheet1.FitColWidth();
	}
	
	
	/**
	 *	IBSheet Event: DBLCLICK
	 */
	 function sheet1_OnDblClick(Row, Col, Value, CellX, CellY, CellW, CellH) {
		 if(Row == 0)return;
		if (Col == 7) {
			var status = sheet1.GetCellValue(Row,8);
			$("#BID_DEG").val(sheet1.GetCellValue(Row, "BID_DEG"));
			$("#BID_NO").val(sheet1.GetCellValue(Row, "BID_NO"));
			$("#DEMANDED_ID").val(sheet1.GetCellValue(Row, "DEMANDED_ID"));
			$("#fevent").val("FORM_SELECT");
			$("#form1").attr("action", "/bid/purchase/BidOpen.screen");
			$("#form1").attr("target", "_self");
			$("#form1").attr("method", "post");
			$("#form1").submit();
		}
	 }

	
	function sheet1_OnSmartResize(Width, Height) { 
		sheet1.FitColWidth();
		autoResize();
	}

	function autoResize(){
		var t1_height = document.getElementById("search-table").scrollHeight + document.getElementById("title").scrollHeight + 24;
		var iframeHeight= document.body.scrollHeight - t1_height;   
		var iframeWidth= document.body.scrollWidth;   
		sheet1.SetSheetHeight(iframeHeight); 
	}	



</SCRIPT>


<modular:search id="form1">
	<modular:key id="fevent" />
</modular:search>
<form id="form1" name="form1" method="post" modular:type="search">
<TABLE id="t1" border="0" cellspacing="0" cellpadding="0" width="100%" height="100%">
<INPUT type="hidden" name="p_user_sabun" value="">
<INPUT type="hidden" name="fevent" id="fevent" value="">
<INPUT type="hidden" name="BID_NO" value="">
<INPUT type="hidden" name="BID_DEG" value="">
<INPUT type="hidden" name="DEMANDED_ID" value="">

<div align="left" id="title" >
    <ul><li>구매_견적서개찰</li></ul>
</div>

<!-- 검색조건 영역 : 시작 -->
<TR><TD height="1">

<!-- 검색조건 영역 : 시작 -->
<TR><TD height="1">
	<!-- 검색조건 시작 -->
		<table id="search-table" class="search-form-table" >
		<colgroup>
			<col width="100" />
			<col width="40%"/>
			<col width="100" />
			<col/>
			<col width="150" />
		</colgroup>
		<tr>
			<th>현장</th>
			<td>
		   		<%=InputText.getSiteCodeNew("p_dept_cd", "p_dept_nm", "", user, params.get("p_dept_cd"), params.get("p_dept_nm"))%>
			</td>
			<th>입찰공고명</th>
			<td>
		   		<%= InputText.get("P_BID_MASTER_NM", params.get("P_BID_MASTER_NM"), 80, 50, "hangule, desc=입찰공고명, PerSize") %>
			</td>
			<td class="button" >
				<span class="btnSearch center" id="btnSearch"><a href="javascript:void(0);">검색</a></span>
				<span class="btnSearch center" id="btnExcel"><a href="javascript:sheetExcelDown(sheet1,$('li').html());">ExcelDown</a></span>
			</td>
		</tr>
</table>
</TD></TR>
<!-- 검색조건 영역 : 종료 -->

<!-- 검색조건 영역, 테이터 영역 구분 여백 : 시작 -->
<TR><TD height="1">
<TABLE border="0" cellspacing="0" cellpadding="0" class="search_data_div_height">
<TR><TD></TD></TR>
</TABLE>
</TD></TR>

<!-- 검색조건 영역, 테이터 영역 구분 여백 : 종료 -->
</TABLE>
	<div id="sheet1_div" style="padding-top:5px;height: auto; min-height: 400px; overflow: auto;">
		<script>createIBSheet('sheet1','100%', '400px');</script>
	</div>
</FORM>
