<%--
  - Author(s)  : Hyung min Son
  - Date       : 2014.06.18
  - 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="com.udapsoft.waf.common.ui.InitCombo" %>
<%@ page import="kr.co.udapsoft.common.code.CommCodeManager" %>
<%@ 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();
    
	//공통코드
	CommCodeManager commCodeManager = new CommCodeManager();
	InitCombo initCombo = new InitCombo();

	initCombo.makeComboData(commCodeManager.getCodeRowSet("ONBID"), "NAME", "CODE");
	String ONBID_CD = initCombo.getCode();
	String ONBID_NM = initCombo.getCodeName();
	
	InitCombo initCombo2 = new InitCombo();
	initCombo2.makeComboData(commCodeManager.getCodeRowSet("DEMANDDED_STATUS"), "NAME", "CODE");
	String DEMANDDED_STATUS_CD = initCombo2.getCode();
	String DEMANDDED_STATUS_NM = initCombo2.getCodeName();

	
	InitCombo initCombo3 = new InitCombo();
	initCombo3.makeComboData(commCodeManager.getCodeRowSet("PR_TYPE"), "NAME", "CODE");
	String PR_TYPE_CD = initCombo3.getCode();
	String PR_TYPE_NM = initCombo3.getCodeName();

	
	
	if(params.get("P_DEMANDED_STATUS").isEmpty()){
		params.set("P_DEMANDED_STATUS","3");
	}
	
%>
<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
		 */
		jQuery("#btnSearch").click(function() {
			jQuery("#fevent").val("SHEET_SELECT");
			var url = Modular.model.PageContext.CONTEXT_ROOT + "/bid/purchase/OrderReqeustListTypeB_sheet.screen";
			Modular.view.IBSheet7.doSearch(sheet1, url, jQuery("#form1"), 30, "");
		});
		
/* 		$("#P_DEMANDED_STATUS").change(function(){
			$("#btnSearch").click();
		}); */
		
		$("#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_DEMANDED_TITLE").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:0, 			Align:"Center",		Hidden:"True"},
		    			{Header:'입찰방법',					Type:"Combo", 		SaveName:"ONBID_YN", 					Width:0,				Align:"Center",		ComboText:"<%=ONBID_NM%>", ComboCode:"<%=ONBID_CD%>"},
		    			{Header:'발주의뢰타입',					Type:"Combo", 		SaveName:"PR_TYPE", 					Width:70,				Align:"Center",		ComboText:"<%=PR_TYPE_NM%>", ComboCode:"<%=PR_TYPE_CD%>"},
		    			{Header:'현장',						Type:"Text", 			SaveName:"DEPT_NM", 						Width:200, 			Align:"Left"},
		    			{Header:'발주의뢰번호',				Type:"Text", 			SaveName:"DEMANDED_NO", 				Width:150, 			Align:"Center"},
		    			{Header:'☞발주의뢰명',				Type:"Text",	 		SaveName:"DEMANDED_TITLE", 			Width:200, 			Align:"Left", 		Cursor:"pointer"},
		    			{Header:'발주의뢰 부서',			Type:"Text", 			SaveName:"BUSEO_NM", 					Width:0, 			Align:"Center"},
		    			{Header:'발주의뢰자',				Type:"Text", 			SaveName:"EMP_NM", 						Width:0, 			Align:"Center"},
		    			{Header:'발주의뢰자',				Type:"Text", 			SaveName:"EMP_NO", 						Width:0, 			Align:"Center",		Hidden:"True"},
		    			{Header:'발주의뢰일',				Type:"Text", 			SaveName:"DEMANDED_DATE", 			Width:0, 			Align:"Center"},
		    			{Header:'접수자',					Type:"Text", 			SaveName:"RECEIPT_NM", 					Width:0, 			Align:"Center"},
		    			{Header:'접수자',					Type:"Text", 			SaveName:"RECEIPT_NO", 					Width:0, 			Align:"Center",		Hidden:"True"},
		    			{Header:'상태',						Type:"Combo", 		SaveName:"DEMANDED_STATUS", 		Width:50, 			Align:"Center",		ComboText:"<%=DEMANDDED_STATUS_NM%>", ComboCode:"<%=DEMANDDED_STATUS_CD%>"},
		    			{Header:'BID_DEG',				Type:"Text", 			SaveName:"BID_DEG", 						Width:100, 			Align:"Center",		Hidden:"True"},
		    			{Header:'DEMANDED_ID',		Type:"Text", 			SaveName:"DEMANDED_ID", 				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; 
		}
	}

	/**
	 *	IBSheet Event: Search End(IBSheet 데이터 조회 CallBack)
	 */
	function sheet1_OnSearchEnd(code, message) {
	    if(code == 0) {
	    	setGridSize();
	    	sheet1.SetColFontColor("DEMANDED_TITLE", "#0000ff");
		} else {
			//조회 에러 수행
			alert(message);
		}
	}
	
	/**
	 *	IBSheet Event: Click
	 */
	function sheet1_OnDblClick(Row, Col, Value, CellX, CellY, CellW, CellH) {
		 if(Row == 0)return;
		 if (Col == 7) {
				jQuery("#DEMANDED_ID").val(sheet1.GetCellValue(Row, "DEMANDED_ID"));
				jQuery("#BID_NO").val(sheet1.GetCellValue(Row, "BID_NO"));
				jQuery("#BID_DEG").val(sheet1.GetCellValue(Row, "BID_DEG"));
				jQuery("#fevent").val("FORM_SELECT");
				jQuery("#form1").attr("action", "/bid/purchase/OrderReqeustTypeB.screen");
				jQuery("#form1").attr("target", "_self");
				jQuery("#form1").attr("method", "post");
				jQuery("#form1").submit();
			}
	}
	
	/**
	 *	IBSheet size setting
	 */
	function setGridSize() {
		sheet1.FitColWidth();
	}
	
	
	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); 
	}	
	
	function seacrch(){
		jQuery("#fevent").val("SHEET_SELECT");
		var url = Modular.model.PageContext.CONTEXT_ROOT + "/bid/purchase/OrderReqeustListTypeB_sheet.screen";
		Modular.view.IBSheet7.doSearch(sheet1, url, jQuery("#form1"), 30, "");
	}

</SCRIPT>


<modular:search id="form1">
	<modular:key id="fevent" />
</modular:search>
<BODY onresize="autoResize()" >
<form id="form1" name="form1" method="post" modular:type="search">
<TABLE id="t1" border="0" cellspacing="0" cellpadding="0" width="100%" height="100%">

<TR><TD height="1">
<INPUT type="hidden" name="p_user_sabun" value="">
<INPUT type="hidden" name="fevent" id="fevent" value="">
<INPUT type="hidden" name="p_user_pw" value="">
<INPUT type="hidden" name="P_DEMANDED_KIND" value="O">
<INPUT type="hidden" name="p_tel_no" value="">
<INPUT type="hidden" name="p_hand_tel_no" value="">
<INPUT type="hidden" name="BID_DEG" value="">
<INPUT type="hidden" name="BID_NO" value="">
<INPUT type="hidden" name="DEMANDED_ID" value="">

<INPUT type="hidden" name="j_usertype" value="head">
<input type='hidden' name='login_id' >
<input type='hidden' name='login_pw' >
<INPUT type="hidden" name="j_admin_login_gb" value="Y">

</TD></TR>
<div align="left" id="title" >
    <ul><li>구매_발주의뢰조회</li></ul>
</div> 

<!-- 검색조건 영역 : 시작 -->
<TR><TD height="1">
	<!-- 검색조건 시작 -->
		<table id="search-table" class="search-form-table" >
		<colgroup>
			<col width="100" />
			<col/>
			<col width="100" />
			<col/>
			<col width="150" />
			<col/>
			<col width="150" />
		</colgroup>
		<tr>
			<th>현장</th>
			<td colspan="5">
				<%-- <%=InputText.getSiteCode("p_dept_cd", "p_dept_nm", "", user, params.get("p_dept_cd"), params.get("p_dept_nm"))%> --%>
				<%=InputText.getSiteCodeNew("p_dept_cd", "p_dept_nm", "", user, params.get("p_dept_cd"), params.get("p_dept_nm"))%>
			</td>
			<td class="button" rowspan="2">
				<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>
		<tr>
			<th>발주의뢰명</th>
			<td>
				<INPUT type="text" name="P_DEMANDED_TITLE" id="P_DEMANDED_TITLE" class="input" value="<%=params.get("P_DEMANDED_TITLE") %>" style="width:90%">
			</td>
			<th>상태</th>
			<td>
					<%=CommCodeManager.getSelectCodeList("DEMANDDED_STATUS","P_DEMANDED_STATUS","height=18;width:80px;","<option value=''>--전체--</option>",params.get("P_DEMANDED_STATUS")) %>
			</td>
			<th>발주의뢰타입</th>
			<td>
					<%=CommCodeManager.getSelectCodeList("PR_TYPE","P_PR_TYPE","height=18;width:80px;","<option value=''>--전체--</option>",params.get("P_PR_TYPE")) %>
			</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%', '450px');</script>
	</div>
</FORM>