<%@ page contentType="text/html; charset=utf-8" %>
<%@ page import="kr.co.udapsoft.common.*" %>
<%@ page import="com.udapsoft.waf.system.*" %>
<%@ page import="com.udapsoft.waf.common.*" %>
<%@ page import="com.udapsoft.waf.common.ui.HTMLMaker" %>
<%@ page import="com.udapsoft.waf.system.HandlerStorage" %>
<%@ page import="kr.co.hsnc.common.util.*"%>
<%@ page import="kr.co.hsnc.common.util.ValueObject" %>
<%@ page import="kr.co.hsnc.common.sql.*" %>
<%@ page import="kr.co.hsnc.common.sql.RowSet" %>
<%@ page import="kr.co.hsnc.common.sql.util.*" %>

<%-- <%@ 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 = ctx.getUser();
%>

<%@ page contentType="text/html; charset=utf-8" %>
<SCRIPT language="JavaScript">
var sheet1;
var sheet1Row;
var sheet1PageNo = 1;
var pageLastRowIndex = 1;
var validationResult = false;
var filterShow = false;

	/* 
	// Sheet
	function initIBSheet(sheetObj) {
		if( sheetObj.id == "sheet1" ) {
			with(sheetObj) {
			
				SheetWidth = 610;
				AutoSizeMode =true;
				MergeSheet = msNone;
				
				Editable = false;

				InitRowInfo( 1, 1, 16, 50);
  
    			InitColumnInfo(5, 0, 0, true);
    			
    			InitHeadMode(true, true, false, true, true, true);

    			InitHeadRow(0, "Site Code|Site|Division|REP_DEPT_CD|진행", false);

    			InitDataProperty(0,	 0,	    dtData,   	 120,    daCenter,	false, "DEPT_CD");
    			InitDataProperty(0,  1,     dtData,    	 340,    daLeft, 	false, "DEPT_NM");
    			InitDataProperty(0,  2,	    dtCombo,     120,	 daCenter,  false, "AC_UNIT_CD");
    			InitDataProperty(0,  3,		dtHidden,      0,    daCenter, 	false, "REP_DEPT_CD");
    			InitDataProperty(0,  4,		dtHidden,      0,    daCenter, 	false, "PRJ_OK");

			    InitDataCombo (0, 2, "토건사업본부|플랜트사업본부|발전사업본부|해외법인및계열사","10|20|60|50", "");
			   
				//Sheet 
			    Visible = true;
			}
		}
	}
 */
 
 	function gridInit(sheetName){
		var init_sheet = {};
		init_sheet.Cfg = {SearchMode:2, Page:30};
		init_sheet.Cols = [
			       			{Header:'Site Code',	Type:"Text",	SaveName:"DEPT_CD", 	Width:120, 	Align:"Center"},
			    			{Header:'Site',			Type:"Text", 	SaveName:"DEPT_NM",		Width:340, 	Align:"Left"},
			    			{Header:'Division',		Type:"Combo", 	SaveName:"AC_UNIT_CD", 	Width:120,	Align:"Center", ComboText:"토건사업본부|플랜트사업본부|발전사업본부|해외법인및계열사", ComboCode:"10|20|60|50"},
			    			{Header:'REP_DEPT_CD',	Type:"Text", 	SaveName:"REP_DEPT_CD", Width:0, 	Align:"Center"},    
			    			{Header:'진행',			Type:"Text", 	SaveName:"PRJ_OK", 		Width:0, 	Align:"Center"  },
		];

		init_sheet.HeaderMode = {Sort:1};
		IBS_InitSheet(sheetName, init_sheet);
		sheetName.SetDataAutoTrim(0);
		setGridSize();
		sheet1.FocusEditMode = 0;
	}
 
	function doSearch() {
		jQuery("#event").val("GET_DEPT_LIST");
		var url = Modular.model.PageContext.CONTEXT_ROOT + "/lib/dlgSearchSpotDept_sheet.screen";
		Modular.view.IBSheet7.doSearch(sheet1, url, jQuery("#form01"), 30, "");
	}

	function sheet1_OnSearchEnd(code, message) {
	    if(code == 0) {
	    	setGridSize();
		} else {
			//조회 에러 수행
			alert(message);
		}
	}

	function doPageInit() {
		gridInit(sheet1);
		doSearch();
		
	}

	function setGridSize() {
		sheet1.FitColWidth();
	}
	
	//document.body.onresize = addEvent( document.body.onresize, "doResizeSheet(document.all.sheet1)");
	document.body.onload = doPageInit;


</SCRIPT>
<script language="javascript" for="sheet1" event="OnDblClick(Row, Col)">
  //팝업을 연 sheet에 값 설정
	var dept_cd, dept_nm
  
	dept_cd = CellValue(Row, 0);
	dept_nm = CellValue(Row, 1);
	
	returnValue = new Array(dept_cd, dept_nm);
	
	window.close();
</script>


<SCRIPT language="JavaScript">

    function doSubmit()
    {       		
		var f = document.form01;
		doSearch();
    }
    
	function doClose()
	{
     	returnValue = null;
     	close();
	}

	function prcKeyPress()
	{
  	  	if( event.keyCode == 13 )
  	  	{
			doSubmit();
		}
	}

	var argObj = window.dialogArguments;
	var title = argObj.title; 
	var inDeptCD = argObj.inDeptCD;  
    
</script>

<TABLE border="0" cellspacing="0" cellpadding="0" width="100%" height="100%">
  <TR><TD height="1">



      <TABLE cellspacing="1" cellpadding="0" class="search_table">
		<FORM name="form01" method="post">
		<INPUT type="hidden" name="site_code" >
		<INPUT type="hidden" name="site_ac_unit_cd" >
		<INPUT type="hidden" name="IN_DEPT_CD" >
		<INPUT type="text" value="자동 Submit을 막기 위해서 있는 필드" size="0" style="display:none;">
        <TR height="25"> 
          <TD width="100" class="search_table_title">
              <img src="/img/buyer/button/bullet_01.gif" align="middle">Site
          </TD>
          <TD class="search_table_data">
            &nbsp;
            <INPUT  class="input" type="text" name="dept_nm" size="27" value="" onKeyPress="prcKeyPress()" style="font-family:'굴림'; font-size:9pt; IME-MODE : active;">
          </TD>

          <TD width="80" rowspan="5" class="search_button"> 
            <TABLE border="0" cellpadding="0" cellspacing="0" align="center">
              <TR> 
                <TD> <DIV onclick="JavaScript:doSubmit();" class="button_style"> 
                    <TABLE border="0" cellpadding="0" cellspacing="0">
                      <TR> 
                        <TD class="button_left1"></TD>
                        <TD class="button_text1">Search</TD>
                        <TD class="button_right"></TD>
                      </TR>
                    </TABLE>
                  </DIV></TD>
			  </TR>
              <TR>
                <TD height="5"></TD>
              </TR>
              <TR>
                <TD> <DIV onclick="JavaScript:doClose();" class="button_style"> 
                	<TABLE border="0" cellpadding="0" cellspacing="0">
                      <TR> 
                      	<TD class="button_left1"></TD>
                      	<TD class="button_text1">&nbsp;&nbsp;Close</TD>
                      	<TD class="button_right"></TD>
                      </TR>
                    </TABLE>
                  </DIV></TD>
              </TR>
            </TABLE>
          </TD>
        </TR>


        <TR height="25"> 
          <TD class="search_table_title">
              <img src="/img/buyer/button/bullet_01.gif" align="middle">Division
          </TD>
          <TD class="search_table_data">&nbsp;
          	<select class='input_select' style="width:50%" name="ac_unit_cd" id="ac_unit_cd" onChange="doSubmit();">
				<option value=''>All</option>
				<option value='10'>토건사업본부</option>
				<option value='10'>플랜트사업본부</option>
				<option value='60'>발전사업본부</option>
				<option value='50'>해외법인및계열사</option>
			</select>
          </TD>
        </TR>

        <TR height="25"> 
          <TD class="search_table_title">
              <img src="/img/buyer/button/bullet_01.gif" align="middle">Status
          </TD>
          <TD class="search_table_data">&nbsp;
			<LABEL for="deadflg_0"><INPUT id="deadflg_0" type="radio" name="deadflg" value="" onClick="doSubmit();" >All</LABEL>
			<LABEL for="deadflg_1"><INPUT id="deadflg_1" type="radio" name="deadflg" value="0" onClick="doSubmit();" checked>Ongoing</LABEL>
			<LABEL for="deadflg_2"><INPUT id="deadflg_2" type="radio" name="deadflg" value="1" onClick="doSubmit();">Complete</LABEL>
          </TD>
        </TR>
		</FORM>
      </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>

  <TR><TD id="sheet1_td">
		<SCRIPT>
			createIBSheet('sheet1','100%', '100%');
		</SCRIPT>
  </TD></TR>
</TABLE>
