<? if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가 ?>

<table border=0 class="admin_head">
<tr>
<th><h2 class="sub_title left">▶ 일반 관리</h2></th>
<td><?=$amina_btn?></td>
</tr>
</table>

<table border=0 class="admin_tbl">
<colgroup>
	<col class="w120">
	<col class="w120">
	<col class="w120">
	<col class="w120">
	<col class="w120">
	<col class="w120">
	<col>
</colgroup>
<tr>
<th>XP측정</th>
<th>XP리셋</th>
<th>설정값</th>
<th>썸네일</th>
<th>글반응</th>
<th>회원사진</th>
<th>&nbsp;</th>
</tr>
<tr>
<td align=center>
	<input type="button" value="측정하기" onclick="amina_win('<?=AMINA_URL?>/recheck.exp.php',700,600,1);" class="btn_red">
</td>
<td align=center>
	<input type="button" value="일괄산출" onclick="amina_win('<?=AMINA_URL?>/reset.exp.php');" class="btn_blue">
</td>
<td align=center>
	<input type="button" value="일괄정리" onclick="amina_win('<?=AMINA_URL?>/reset.set.php');" class="btn_red">
</td>
<td align=center>
	<input type="button" value="일괄삭제" onclick="amina_win('<?=AMINA_URL?>/reset.thumb.php');" class="btn_blue">
</td>
<td align=center>
	<input type="button" value="일괄정리" onclick="amina_win('<?=AMINA_URL?>/reset.response.php');" class="btn_red">
</td>
<td align=center>
	<input type="button" value="일괄정리" onclick="amina_win('<?=AMINA_URL?>/reset.photo.php');" class="btn_blue">
</td>
<td>&nbsp;</td>
</tr>
</table>

<table border=0 class="admin_head">
<tr>
<th><h2 class="sub_title left">▶ 기능 설정 DB 관리</h2></th>
<td>&nbsp;</td>
</tr>
</table>

<form name="fma" method="post" action="#" onsubmit="return fma_submit(this,'func');">
<input type="hidden" name="ma" value="func">
<input type="hidden" name="loc" value="<?php echo $loc; ?>">
<input type="hidden" name="bo_table" value="<?php echo $bo_table; ?>">

<table border=0 class="admin_tbl">
<colgroup>
	<col class="w20">
	<col class="w120">
	<col>
	<col class="w60">
	<col class="w60">
	<col class="w60">
	<col class="w60">
</colgroup>
<tr>
<th><input type="checkbox" class="all_func_chk"></th>
<th>게시판 ID</th>
<th>&nbsp;</th>
<th>&nbsp;</th>
<th>&nbsp;</th>
<th>&nbsp;</th>
<th>&nbsp;</th>
</tr>
<? 
	$result = sql_query(" select * from {$g5['amina']} order by bo_table ", false); 
	$i = 0;
	while ($row = sql_fetch_array($result)) { 
		$bg = $i%2 ? '' : ' class="bg_gray"';
		echo "<tr".$bg.">";
		echo "<td><input type=\"checkbox\" name=\"chk_func_id[]\" value=\"".$i."\"><input type=\"hidden\" name=\"ma_id[".$i."]\" value=\"".$row['id']."\"></td>";
		echo "<td>".$row['bo_table']."</td>";
		echo "<td>&nbsp;</td>";
		echo "<td><a href=\"".AMINA_URL."/admin.dashboard.php?loc=func&bo_table=".$row['bo_table']."\">수정</a></td>";
		echo "<td><a href=\"".AMINA_URL."/admin.update.php?loc=ma&type=func&bo_table=".$bo_table."&id=".$row['id']."\">삭제</a></td>";
		echo "<td><a href=\"".G5_BBS_URL."/board.php?bo_table=".$row['bo_table']."\">보기</a></td>";
		echo "<td><a href=\"javascript:amina_win('".AMINA_URL."/admin.copy.php?type=func&id=".$row['id']."');\">복사</a></td>";
		echo "</tr>\n";
		$i++;
	}
?>
</table>
<p><button type="submit" class="btn_gray">선택삭제</button> <label><input type="checkbox" class="all_func_chk"> 전체선택</label></p>
</form>

<table border=0 class="admin_head">
<tr>
<th><h2 class="sub_title left">▶ 스킨 설정 DB 관리</h2></th>
<td>&nbsp;</td>
</tr>
</table>

<form name="fma" method="post" action="#" onsubmit="return fma_submit(this,'skin');">
<input type="hidden" name="ma" value="skin">
<input type="hidden" name="loc" value="<?php echo $loc; ?>">
<input type="hidden" name="bo_table" value="<?php echo $bo_table; ?>">

<table border=0 class="admin_tbl">
<colgroup>
	<col class="w20">
	<col class="w80">
	<col class="w120">
	<col class="w160">
	<col>
	<col class="w60">
	<col class="w60">
	<col class="w60">
	<col class="w60">
</colgroup>
<tr>
<th><input type="checkbox" class="all_skin_chk"></th>
<th>&nbsp;</th>
<th>게시판 ID</th>
<th>카테고리</th>
<th>&nbsp;</th>
<th>&nbsp;</th>
<th>&nbsp;</th>
<th>&nbsp;</th>
<th>&nbsp;</th>
</tr>
<? 
	$result = sql_query(" select * from {$g5['amina_skin']} order by bo_table, skin_type, sca desc ", false); 
	$i = 0;
	while ($row = sql_fetch_array($result)) { 
		$bg = $i%2 ? '' : ' class="bg_gray"';
		$c_type = $row['sca'] ? $row['sca'] : '전체(공통)';
		if($row['skin_type'] > 1) { //PC
			$s_type = '모바일';
			$l_type = 'm';
			$o_type = '&device=mobile';
		} else {
			$s_type = 'PC';
			$l_type = 'pc';
			$o_type = '';
		}
		echo "<tr".$bg.">";
		echo "<td><input type=\"checkbox\" name=\"chk_skin_id[]\" value=\"".$i."\"><input type=\"hidden\" name=\"ma_id[".$i."]\" value=\"".$row['id']."\"></td>";
		echo "<td>".$s_type."</td>";
		echo "<td>".$row['bo_table']."</td>";
		echo "<td>".$c_type."</td>";
		echo "<td>&nbsp;</td>";
		echo "<td><a href=\"".AMINA_URL."/admin.dashboard.php?loc=".$l_type."&bo_table=".$row['bo_table']."&sca=".urlencode($row['sca'])."\">수정</a></td>";
		echo "<td><a href=\"".AMINA_URL."/admin.update.php?loc=ma&type=skin&bo_table=".$row['bo_table']."&id=".$row['id']."\">삭제</a></td>";
		echo "<td><a href=\"".G5_BBS_URL."/board.php?bo_table=".$row['bo_table'].$o_type."\">보기</a></td>";
		echo "<td><a href=\"javascript:amina_win('".AMINA_URL."/admin.copy.php?type=skin&id=".$row['id']."');\">복사</a></td>";
		echo "</tr>\n";
		$i++;
	}
?>
</table>

<table border=0 class="admin_head no_margin">
<tr>
<th><p style="font-weight:normal;"><button type="submit" class="btn_gray">선택삭제</button> <label><input type="checkbox" class="all_skin_chk"> 전체선택</label></p></th>
<td><?=$amina_btn?></td>
</tr>
</table>

</form>

<script>
	$(function(){
		$('.all_func_chk').click(function(){
			$('[name="chk_func_id[]"]').attr('checked', this.checked);
		});

		$('.all_skin_chk').click(function(){
			$('[name="chk_skin_id[]"]').attr('checked', this.checked);
		});
	});

	function fma_submit(f,opt) {
		var cnt = 0;
		if(opt == "func") {
			for (var i=0; i<f.length; i++) {
				if (f.elements[i].name == "chk_func_id[]" && f.elements[i].checked)
				cnt++;
			}
		} else {
			for (var i=0; i<f.length; i++) {
				if (f.elements[i].name == "chk_skin_id[]" && f.elements[i].checked)
				cnt++;
			}
		}

		if (!cnt) {
			alert("삭제할 설정을 하나 이상 선택하세요.");
			return false;
		}

		if (!confirm("선택한 설정을 정말 삭제 하시겠습니까?\n\n한번 삭제한 자료는 복구할 수 없습니다")) {
			return false;
		}

		f.action = "<?php echo AMINA_URL; ?>/admin.update.php";

		return true;
	}
</script>