<%--
  - FileName   : UserBoardList.jsp
  - Author(s)  : Son Hyung Min
  - Date       : 2007.05.16
  - Copyright  : Copyright (c) 2002-2007 www.hwenc.com, Inc.
  - 
  - Description: 공지사항
  --%>

<%@page import="utils.system"%>
<%@ page contentType="text/html; charset=utf-8"%>
<%@ page import="hwenc.system.HandlerStorage"%>
<%@ page import="hwenc.common.ui.*"%>
<%@ page import="kr.co.hsnc.common.util.*"%>
<%@ page import="kr.co.hsnc.common.sql.*"%>
<%@ page import="kr.co.hsnc.common.base.WAFLogger"%>

<jsp:useBean id="ctx" class="hwenc.system.context.SessionContext" scope="session" />

<%
	ctx.init(request, response);
	HandlerStorage storage = ctx.getHandlerStorage();
	ValueObject params = storage.getParams();
	ValueObject user = storage.getUser();
	String event = storage.getEvent();
	
	//String deptCd =   params.get("dept_cd",user.get("site_code"));
	//String deptName = params.get("dept_mn",user.get("site_name"));
	
	
	
	//deptCd = params.get("buseo");
	

	RowSet rowSet = storage.getRowSet("ROWSET");
	RowSet acctTypeRowSet = storage.getRowSet("AcctTypeRowSet"); //계정 타입
	//System.out.println("acctyType:"+acctTypeRowSet);
	//System.out.println("rowSet:"+rowSet);
%>

<SCRIPT language="JavaScript" src="/js/select.js"></SCRIPT>
<SCRIPT language="JavaScript" src="/js/lib.js"></SCRIPT>
<SCRIPT language="JavaScript" src="/js/broswer.js"></SCRIPT>
<script type="text/javascript" src="/js/createIBUploader.js"></script>
<script type="text/javascript" src="/js/IBUploaderInfo.js"></script>

<SCRIPT language="JavaScript">
	var myUpload = null;
	/*예약함수*/
	// Sheet의 초기화 작업
	function initIBSheet(sheetObj) {
        
		if( sheetObj.id == "sheet1" ) {
            
			with(sheetObj) {
			
				//전체 너비 설정
				doResizeSheet(sheetObj);

				//전체Merge 종류 [선택, Default msNone]
				MergeSheet = msNone;
				
				//전체Edit 허용 여부 [선택, Default false]
				Editable = false;

				//행정보설정[필수][HEADROWS,DATAROWS,VIEWROWS,ONEPAGEROWS=100]
				InitRowInfo( 1, 1, 20);
  
    			//컬럼정보설정[필수][COLS,FROZENCOL,LEFTHEADCOLS=0,FROZENMOVE=false]
    			InitColumnInfo(11, 3, 0, true);
    			
    			InitHeadMode(true, false, false, true); 

    			//해더행정보[필수][ROW,HEADTEXT,ROWMERGE=false, HIDDEN=false]
    			InitHeadRow(0, "삭제|Status|NO|등록일자|☞제목|업체공지여부|등록자|번호|내용|REAL_FILE_NAME|FILE_SIZE", false);

				var colNum = 0; 
    			//데이터속성[ROW,COL,DATATYPE,WIDTH,DATAALIGN,COLMERGE,SAVENAME,KEYFIELD,CALCULOGIC,DATAFORMAT,POINTCOUNT,UPDATEEDIT,INSERTEDIT,EDITLEN,FULLINPUT,SORTENABLE,TOOLTIP,ALLCHECK, SAVESTATUS, FORMATFIX]    
    			InitDataProperty(0,	colNum++,	dtHidden,   	 	 50,    daCenter, 	false, "DEL_CHECK");
    			InitDataProperty(0, colNum++, 	dtHiddenStatus,    	 80,    daCenter, 	false, "STATUS");
    			InitDataProperty(0, colNum++,	dtDataSeq,   		 30,    daCenter, 	false, "NO");
    			InitDataProperty(0, colNum++,	dtData,      		 60,    daCenter, 	false, "REG_DD");
    			InitDataProperty(0, colNum++,	dtData,      		 320,   daLeft, 	false, "BOARD_TITLE");
    			InitDataProperty(0, colNum++,	dtData,      		 30,    daCenter, 	false, "COMPANY_VIEW_YN");
    			InitDataProperty(0, colNum++,	dtData, 			 50,    daCenter,   false, "REG_ID");
    			InitDataProperty(0, colNum++,	dtHidden,  			  0,      daLeft,   false, "BOARD_ID");
    			InitDataProperty(0, colNum++,	dtHidden,  			  0,      daLeft,   false, "BOARD_CONTENT");
    			InitDataProperty(0, colNum++,	dtHidden,  			  0,      daLeft,   false, "REAL_FILE_NAME");
    			InitDataProperty(0, colNum++,	dtHidden,  			  0,      daLeft,   false, "FILE_SIZE");
				
				//Sheet 나타나도록 설정
			    Visible = true;
			    ActionMenu = "엑셀다운로드";

			    //마우스 오버시 손모양 표시
			    DataLinkMouse("BOARD_TITLE")  = true;

			}
		}
	}
	//검색
	function doSearch() {
	    searchIBSheet("/UserBoardList_Srch.screen", "SELECT", document.form1, document.all.sheet1);
		doResizeSheet(document.all.sheet1);
		goRegProc();
	}


	//저장 처리
	function doSave() {
		var f = document.form1;
		if (f.P_COMPANY_VIEW_YN.checked)  {
            f.COMPANY_VIEW_YN.value = 'Y';
        } else {
           f.COMPANY_VIEW_YN.value = 'N';
        }
		

		if(dlgConfirm("저장 하시겠습니까?")){
			var event_value = "";
			//f.action = "/UserBoardList_data.screen";
			//f.target = "worker";
			if(document.form1.BOARD_ID.value == null || document.form1.BOARD_ID.value == ""){
				//f.event.value = "INSERT";
				event_value = "INSERT";
			}else{
				//f.event.value = "UPDATE";
				event_value = "UPDATE";
			}
			//formSubmit(f);
			submitXmlRequest("UserBoardList_data.screen", event_value, document.form1);
			f.event.value="";
		}
		
	}
	
	function doDelete(){
		if(document.form1.BOARD_ID.value == null || document.form1.BOARD_ID.value == ""){
			dlgAlert("신규는 삭제 할 수 없습니다.");
			return;
		}
		document.form1.DEL_YN.value = "Y";
		//var f = document.form1;
		//f.action = "/UserBoardList_data.screen";
		//f.target = "worker";
		//f.event.value = "DELETE";
		//formSubmit(f);
		
		submitXmlRequest("UserBoardList_data.screen", "DELETE", document.form1);
	}


	//자동로그인 기능
	function f_gologin(login_id,login_pw){
        
    	var f = document.form1;
    
    	if('<%= user.get("ACCT_TYPE_CODE")%>' != "ADMIN"){
    		dlgAlert("Administrator로 로그인한 사용자만 자동로그인 작업이 가능합니다.");
    		return;
    	}
    
    	f.login_id.value = login_id;
    	f.login_pw.value = login_pw;
    
    	if( !submitXmlRequest("/sign_on_check", "", f) ) {
    		alert("로그인을 처리중입니다.");
    	}
    }

	function doResult(resultObj) {
		alert(resultObj.getRequestEvent());
		try {
    		if( resultObj.getRequestEvent() == "SELECT" ) {
    			if( resultObj.getSuccess() ) {				
    				goRegProc();
    				//OnClick(0,0,"");
    			} else {
    				dlgErrorMsg(resultObj);
    			}
    			document.form1.isSubmit = false;
    		}else if(resultObj.getRequestEvent() == "UPDATE"){
    			if( resultObj.getSuccess() ) {				
    				dlgAlert("저장 되었습니다.");
    				doSearch();
    			} else {
    				dlgErrorMsg(resultObj);
    			}
    		}else if(resultObj.getRequestEvent() == "INSERT"){
    			if( resultObj.getSuccess() ) {				
    				dlgAlert("저장 되었습니다.");
    				doSearch();
    			} else {
    				dlgErrorMsg(resultObj);
    			}    			
    		}else if(resultObj.getRequestEvent() == "DELETE"){
    			if( resultObj.getSuccess() ) {				
    				dlgAlert("삭제 되었습니다.");
    				doSearch();
    			} else {
    				dlgErrorMsg(resultObj);
    			}	
    		}
    	}
    	catch(errorObject) {
            showErrorDlg("doResult()", errorObject);
    	}
    }

    
    //페이지 초기화 함수
	function doPageInit() {
		doSearch();
	    doResizeSheet(document.all.sheet1);
	}
    
    //엑셀다운로드
	function doExcelDown() {
		document.getElementById("sheet1").SpeedDown2Excel(-1);
	}

	//신규등록
	function goRegProc(){
		document.form1.REG_ID.value = "<%=user.get("user_name")%>";
		document.form1.BOARD_TITLE.value = "";
		document.form1.REG_DD.value = "";
		document.form1.BOARD_CONTENT.value = "";
		document.form1.COMPANY_VIEW_YN.value = "";
		document.form1.BOARD_ID.value = "";
		document.form1.P_COMPANY_VIEW_YN.checked = false;
		document.form1.isSubmit = false;
	}

	
	function doUpload(){
		alert(1);
		myUpload.StartUpload();
	}
	
	//페이지 초기화 함수 Call
	document.body.onload = doPageInit;
	document.body.onresize = addEvent( document.body.onresize, "doResizeSheet(document.all.sheet1)");
	
	
	
	
	
	
</SCRIPT>

<script language="JavaScript" for="sheet1" event="OnSearchEnd(ErrMsg)">      
	if(doSearchEnd(ErrMsg)){
		with(sheet1) {
			if(LastRow>1){
				for(i=1; i<=LastRow; i++){
					  document.all.sheet1.ColFontColor(4) = RgbColor(0,0,255);;
				}
			}
		}
	}
</script>

<SCRIPT language="javascript" for="sheet1" event="OnClick(Row,Col,Value)">
		if ( ColSaveName(Col) == "BOARD_TITLE" || ColSaveName(Col) == "BOARD_TITLE") {
		document.form1.REG_ID.value = document.all.sheet1.CellValue(Row, "REG_ID");
		document.form1.BOARD_TITLE.value = document.all.sheet1.CellValue(Row, "BOARD_TITLE");
		document.form1.REG_DD.value = document.all.sheet1.CellValue(Row, "REG_DD");
		document.form1.BOARD_CONTENT.value = document.all.sheet1.CellValue(Row, "BOARD_CONTENT");
		
		if(document.all.sheet1.CellValue(Row, "COMPANY_VIEW_YN") == "Y"){
			document.form1.P_COMPANY_VIEW_YN.checked = true;
		}else{
			document.form1.P_COMPANY_VIEW_YN.checked = false;
		}
		document.form1.BOARD_ID.value = document.all.sheet1.CellValue(Row, "BOARD_ID");
		document.form1.FILE_URL.value = document.all.sheet1.CellValue(Row, "REAL_FILE_NAME");
		document.form1.FILE_SIZE.value = document.all.sheet1.CellValue(Row, "FILE_SIZE");
		
		
		document.form1.isSubmit = false;
	}
</SCRIPT>

  <script language="javascript" for="sheet1" event="OnSelectMenu(sAction)">
      //메뉴에 대한 처리
      switch(sAction){
        case "엑셀다운로드" :
          sheet1.SpeedDown2Excel(-1); break;
      }
  </script>
<FORM name="form1" method="post">
<INPUT type='hidden' name="event"    value="">
<TABLE border="0" cellspacing="0" cellpadding="0" width="100%" height="100%">
	<TR height="5%">
		<TD height="1" colspan="2">
        
		<INPUT type="hidden" name="P_SERCH_BOARD_TITLE" value="">
		<INPUT type="hidden" name="P_REG_ID" value="">
		<INPUT type="hidden" name="P_REG_DD" value="">
		<INPUT type="hidden" name="P_BOARD_TITLE" value="">
		<INPUT type="hidden" name="COMPANY_VIEW_YN" value="">
		<INPUT type="hidden" name="P_BOARD_CONTENT" value="">
		<INPUT type="hidden" name="BOARD_ID" value="">
		<INPUT type="hidden" name="DEL_YN" value="N">
		<INPUT type="hidden" name="P_FILE_URL" value="">
		<INPUT type="hidden" name="P_FILE_SIZE" value="">  
		
		
			<TABLE class="screen_title_table">
					 <TR height="2"><TD colspan="2">&nbsp;</TD></TR>
					<TR height="27">
						<TD width="16" valign="middle"><IMG src="/img/template/bullet_03.gif"></TD>
						<TD width="100%" class="screen_title_text"><%=storage.getPgmName()%></TD>
					</TR>
			</TABLE>
		</TD>
	</TR>
	<!-- 검색조건 영역 : 시작 -->
	<TR>
		<TD colspan="2">
		<TABLE cellspacing="1" cellpadding="0" class="search_table">
			<TR height="26">
				<!-- 검색조건 타이틀 1 -->   
				<TD width="20%" class="search_table_title"><IMG src="/img/temp/bullet_01.gif">제목</TD>
				<TD width="50%" class="search_table_data">&nbsp;<%=InputText.get("SERCH_BOARD_TITLE", params.get("P_SERCH_BOARD_TITLE"), 98, 50, "hangule, desc=제목, PerSize", "", "onkeyup=\"prcKeyPress();\"")%>
				</TD>
				<TD width="30%" align="right">
					<IMG src="/img/button/bt_search.gif" alt="검색" border="0" style="cursor:hand" align="middle" onclick="doSearch();">
					<IMG src="/img/button/bt_user_register.gif" alt="신규" border="0" style="cursor:hand" align="middle" onclick="goRegProc();">&nbsp;
				</TD>
			</TR>
		</TABLE>
		</TD>
	</TR>
	<!-- 검색조건 영역, 테이터 영역 구분 여백 : 종료 -->
	<TR height="200px">
		<TD id="sheet1_td" colspan="2"><SCRIPT>
			var sheetObj = new IBSheetObject("sheet1");
			sheetObj.display();
		</SCRIPT></TD>
	</TR>
	<TR height="29">
		<TD width="80%" class="search_table_title"><IMG src="/img/temp/bullet_01.gif">공지내역</TD>
		<TD class="search_table_title" align="right">
		    	<IMG src="/img/button/bt_save.gif" alt="저장" border="0" style="cursor:hand" onclick="doSave();"  id="bt_save"> 
				<IMG src="/img/button/bt_delete.gif" alt="삭제" border="0" style="cursor:hand" onclick="doDelete();" id="bt_delete"> 
				<!-- IMG src="/img/button/bt_cancel.gif" alt="취소" border="0" style="cursor:hand" id="bt_cancel"-->
		</TD>
	</TR>
	<TR height="10">
	<td>&nbsp;</td>
	</TR>
	<TR>
		<TD colspan="2">
			<TABLE cellspacing="1" cellpadding="0" class="search_table">
				<TR height="26">   
					<TD width="10%" class="search_table_title"><IMG src="/img/temp/bullet_01.gif">등록자</TD>
					<TD width="40%" class="search_table_data">&nbsp;<%=InputText.get("REG_ID", params.get("P_REG_ID"), 50, 50, "hangule, desc=등록자, PerSizem, readonly", "", "onkeyup=\"prcKeyPress();\"")%></TD>
					<TD width="10%" class="search_table_title"><IMG src="/img/temp/bullet_01.gif">등록일자</TD>
					<TD width="40%" class="search_table_data">&nbsp;<%=InputText.get("REG_DD", params.get("P_REG_DD"), 50, 50, "hangule, desc=등록자, PerSize, readonly", "", "onkeyup=\"prcKeyPress();\"")%></TD>
				</TR>
				<TR height="26">
					<TD width="10%" class="search_table_title"><IMG src="/img/temp/bullet_01.gif">제목</TD>
					<TD width="30%" class="search_table_data" colspan="3">&nbsp;<%=InputText.get("BOARD_TITLE", params.get("P_BOARD_TITLE"), 98, 50, "hangule, desc=등록자, PerSize", "", "onkeyup=\"prcKeyPress();\"")%></TD>
				</TR>
				<TR height="26">				
					<TD width="10%" class="search_table_title"><IMG src="/img/temp/bullet_01.gif">업체공지여부</TD>
					<TD width="30%" class="search_table_data" colspan="3"><input type="checkbox" name="P_COMPANY_VIEW_YN" value="Y"></TD>
				</TR>
				<TR height="180">				
					<TD width="10%" class="search_table_title"><IMG src="/img/temp/bullet_01.gif">공지내용</TD>
					<TD width="25%" class="search_table_data" colspan="3">
					<TEXTAREA name="BOARD_CONTENT" rows="14" cols="188" class="input_textarea"></TEXTAREA>
					</TD>
				</TR>
				<TR height="26">
				<TD width="10%" class="search_table_title"><IMG src="/img/temp/bullet_01.gif">첨부파일</TD>
				<TD width="30%" class="search_table_data" colspan="3">&nbsp;<%=InputText.get("FILE_URL", params.get("P_FILE_URL"), 50, 50, "hangule, desc=파일경로, PerSize", "", "onkeyup=\"prcKeyPress();\"")%>
				&nbsp;<%=InputText.get("FILE_SIZE", params.get("P_FILE_SIZE"), 10, 50, "hangule, desc=파일크기, PerSize", "", "onkeyup=\"prcKeyPress();\"")%>
				<IMG src="/img/button/bt_upload.gif" alt="파일업로드" border="0" style="cursor:hand" onclick="doUpload();"  id="bt_upload">
				<IMG src="/img/button/bt_down.gif" alt="파일다운로드" border="0" style="cursor:hand" onclick="doSave();"  id="bt_download">
				</TD>
				</TR>
			</TABLE>
		</TD>
	</TR>
</TABLE>
</FORM>
<IFRAME name="worker" width="0" height="0"></IFRAME>