<?
include $_SERVER[DOCUMENT_ROOT] . "/backoffice/header.php";
include $_SERVER[DOCUMENT_ROOT] . "/module/board/board.lib.php";
include $_SERVER[DOCUMENT_ROOT] . "/common/fckeditor/fckeditor.php";
if(!in_array("board_manage",$_SESSION[$_SITE["DOMAIN"]]["ADMIN"]["AUTH"]) && $_SESSION[$_SITE["DOMAIN"]]["ADMIN"]["GRADE"]!="ROOT"):
	jsMsg("권한이 없습니다.");
	jsHistory("-1");
endif;

$scale="999";

//DB연결
$dblink = SetConn($_conf_db["main_db"]);

$arrList = getArticleList($_conf_tbl["board_info"], $scale, $_REQUEST[offset], "");
//_DEBUG($arrList);
$arrLevel = getArticleList($_conf_tbl["member_level"], 0, 0, "order by level_no desc ");

$arrLevelInfo = getArticleList($GLOBALS["_conf_tbl"]["member_level"], 0, 0, " order by level_no desc ");

for($i=0;$i<$arrLevel["total"];$i++){
	$arrayLevel[$arrLevel["list"][$i][level_no]] = $arrLevel["list"][$i][level_name];
}
//DB해제
SetDisConn($dblink);
?>
<div id="admin-container">
	<? include "menu.php"; ?>
    <div id="admin-content">
		<h2 class="admin-title"><font color="red">게시판 관리(웹사이트용)</font>  <a href="/backoffice/module/board/board.php">[고객용보기]</a></h2> 

		<script language="javascript" src="/common/util.js"></script>
		<script language="javascript">
		function delBoard(idx){
			var cfm;
			cfm =false;
			cfm = confirm("이 게시판을 삭제 하시겠습니까?\n\n관련 데이터들도 모두 삭제되며 복구되지 않습니다.");
			if(cfm==true){
				document.frmBBSHidden.idx.value = idx;
				document.frmBBSHidden.submit();
			}
		}

		function CheckForm(frm){ 
			if (frm.id.value==""){
				alert("ID 를 입력하여 주십시요.");
				frm.id.focus();
				return false;
			}
			if (frm.id.value.length < 2 || frm.id.value.length > 20) {
				alert("ID는 2~20자리입니다.");
				frm.id.focus();
				return false;
			}
			if (hangul_chk(frm.id.value) != true ){
				alert("ID에 한글이나 여백은 사용할 수 없습니다.");
				frm.id.focus();
				return false;
			}

		}
		</script>
		<div class="admin-search">
		  <form name="frmBBS" method="post" action="board_evn.php" onSubmit="return CheckForm(this)">
		  <input type="hidden" name="evnMode" value="createBBS">
			<div class="total">&nbsp;<strong>전체 : <?=number_format($arrList['list']['total'])?> 개</strong></div>
			<div class="keyword">
			  신규 게시판 ID : <input type="text" name="id" size="20" maxlength="20" class="input" /> <span class="btn_pack medium icon"><span class="add"></span><input type="submit" value="게시판 생성"></span>
			</div>
		  </form>
		</div>

		<form name="frmBBS" method="post" action="board_evn.php" onSubmit="return CheckForm(this)">
		<input type="hidden" name="evnMode" value="editAdminBBS">
		<input type="hidden" name="idx" value="<?=$_REQUEST[idx]?>">
		<table class="admin-table-type1">
		<thead>
		<tr>
		  <th width="2%">No.</th>
		  <th width="5%">게시판ID</th>
		  <th width="15%">게시판명</th>
		  <th width="5%">관리자만</th>
		  <th width="5%">자료실</th>
		  <th width="5%">답글</th>
		  <th width="5%">댓글</th>
		  <th width="5%">목록</th>
		  <th width="5%">쓰기</th>
		  <th width="5%">읽기</th>
		  <th width="5%">답글</th>
		  <th width="5%">리스트개수</th>
		  <th width="5%">썸네일</th>
		  <th width="5%">스킨</th>
		  <th width="5%">생성일</th>
		  <th width="5%">관리</th>
		</tr>
		</thead>
		<tbody>
		<?if($arrList['list']['total'] > 0):?>

		<?for ($i=0;$i<$arrList['list']['total'];$i++) {?>
		<input type="hidden" name="sub_idx[]" id="sub_idx[]" value="<?=$arrList["list"][$i][idx]?>"/>
		<tr height="25" align="center" onMouseOver="this.style.backgroundColor='#f8f8f8'"  onMouseOut="this.style.backgroundColor=''">
		  <td><?=number_format($arrList['total']-$i-$offset)?></td>
		  <td><?=$arrList['list'][$i]['boardid']?></td>
		  <td align="left"><input type="text" name="boardname[]" id="boardname[]" value="<?=$arrList["list"][$i][boardname]?>" class="input" style="width:80%"/> <a href="board_view.php?boardid=<?=$arrList['list'][$i]['boardid']?>">[보기]</a></td>
		  <td>
		    <!-- 관리자만 -->
			<select name="f_useadminonly[]" style="width:60px;">
			  <option value="N"<?=$arrList['list'][$i]['useadminonly']=="N"?" selected":""?> style="color:blue">아무나</option>
				<option value="Y"<?=$arrList['list'][$i]['useadminonly']=="Y"?" selected":""?> style="color:red">관리자</option>
			</select>
		  </td>
		  <td>
			<!-- 자료실 -->
			<select name="f_usepds[]" style="width:80px;">
			  <option value="N"<?=$arrList['list'][$i]['usepds']=="N"?" selected":""?> style="color:blue">사용안함</option>
				<option value="Y"<?=$arrList['list'][$i]['usepds']=="Y"?" selected":""?> style="color:red">사용</option>
			</select>
		  </td>
		  <td>
			<!-- 답글 -->
			<select name="f_usereply[]" style="width:80px;">
			  <option value="N"<?=$arrList['list'][$i]['usereply']=="N"?" selected":""?> style="color:blue">사용안함</option>
				<option value="Y"<?=$arrList['list'][$i]['usereply']=="Y"?" selected":""?> style="color:red">사용</option>
			</select>
		  </td>
		  <td>
			<!-- 댓글 -->
			<select name="f_usememo[]" style="width:80px;">
			  <option value="N"<?=$arrList['list'][$i]['usememo']=="N"?" selected":""?> style="color:blue">사용안함</option>
				<option value="Y"<?=$arrList['list'][$i]['usememo']=="Y"?" selected":""?> style="color:red">사용</option>
			</select>
		  </td>
		  <td>
			<select name="f_listlevel[]" style="width:80px;">
				<option value="">목록등급</option>
				<?for($a=0;$a<$arrLevelInfo["total"];$a++){?>
				<option value="<?=$arrLevelInfo["list"][$a]["level_no"]?>"<?=$arrLevelInfo["list"][$a]["level_no"]==$arrList["list"][$i][listlevel]?" selected":""?>><?=$arrLevelInfo["list"][$a]["level_name"]?> 이상</option>
				<?}?>
			</select>
		  </td>
		  <td>
			<select name="f_writelevel[]" style="width:80px;">
				<option value="">쓰기등급</option>
				<?for($a=0;$a<$arrLevelInfo["total"];$a++){?>
				<option value="<?=$arrLevelInfo["list"][$a]["level_no"]?>"<?=$arrLevelInfo["list"][$a]["level_no"]==$arrList["list"][$i][writelevel]?" selected":""?>><?=$arrLevelInfo["list"][$a]["level_name"]?> 이상</option>
				<?}?>
			</select>
		  </td>
		  <td>
			<select name="f_readlevel[]" style="width:80px;">
				<option value="">읽기등급</option>
				<?for($a=0;$a<$arrLevelInfo["total"];$a++){?>
				<option value="<?=$arrLevelInfo["list"][$a]["level_no"]?>"<?=$arrLevelInfo["list"][$a]["level_no"]==$arrList["list"][$i][readlevel]?" selected":""?>><?=$arrLevelInfo["list"][$a]["level_name"]?> 이상</option>
				<?}?>
			</select>
		  </td>
		  <td>
			<select name="f_replylevel[]" style="width:80px;">
				<option value="">답글등급</option>
				<?for($a=0;$a<$arrLevelInfo["total"];$a++){?>
				<option value="<?=$arrLevelInfo["list"][$a]["level_no"]?>"<?=$arrLevelInfo["list"][$a]["level_no"]==$arrList["list"][$i][replylevel]?" selected":""?>><?=$arrLevelInfo["list"][$a]["level_name"]?> 이상</option>
				<?}?>
			</select>
		  </td>
		  <td><input type="text" name="f_scale[]" id="f_scale" value="<?=$arrList["list"][$i][scale]?>" class="input" style="width:50px;"/></td>
		  <td><input type="text" name="f_thumwidth[]" id="f_thumwidth" value="<?=$arrList["list"][$i][thumwidth]?>" class="input" style="width:50px;"/></td>
		  <td>
			<select name="f_skin[]">
			<?
			$dirhandle = opendir($_SITE["BOARD_PATH"]."/skin");
			while($filename = readdir($dirhandle)){
			  if($filename == '.' || $filename == '..'){
			  }else{
				  if($filename==$arrList["list"][$i][skin]){
					echo "<option value='$filename' selected>$filename</option>\n";
				  }else{
					echo "<option value='$filename'>$filename</option>\n";
				  }
			  }
			}
			?>
			</select>
		  </td>
		  <td><?=substr($arrList['list'][$i]['wdate'],2,8)?></td>
		  <td><a href="board_info.php?idx=<?=$arrList['list'][$i]['idx']?>"><img src="/backoffice/images/k_modify.gif" alt="수정" /></a>| <a href="javascript:delBoard('<?=$arrList['list'][$i]['idx']?>');"><img src="/backoffice/images/k_delete.gif" alt="삭제" /></a></td>
		</tr>
		<?}?>

		<?else:?>
		<tr height="100">
		  <td width="100%" colspan="20" >생성된 게시판이 없습니다.</td>
		</tr>
		<?endif;?>
		</tbody>
		</table>

		<div class="paginate">
		  <?=pageNavigation($arrList['total'],$scale,$pagescale,$offset,"")?>
		</div>

		<div class="admin-buttons">
			<div class="cen">
				<span class="btn_pack xlarge icon"><span class="refresh"></span><input type="submit" value="수정하기" style="font-weight:bold" /></span>
			</div>
		</div>
		</form>

		

		<form name="frmBBSHidden" method="post" action="board_evn.php">
		<input type="hidden" name="evnMode" value="deleteAdminBBS">
		<input type="hidden" name="idx">
		</form>


	</div>
</div>
<?
include $_SERVER[DOCUMENT_ROOT] . "/backoffice/footer.php";
?>
