<?
$sub_menu = "400400";
include_once("./_common.php");

auth_check($auth[$sub_menu], "r");

$token		= get_token();
include_once("$g4[path]/head.sub.php");
?>
<script type="text/javascript" src="<?=$g4[path]?>/js/sideview.js"></script>
<style type="text/css">
.info	{ border:1px solid #8397BF; background-color:#F8F8FB; color:#4C596E; text-align:left; padding:5px; margin:10px 0 5px 0; font-family:나눔고딕; }

.trhead td	{ background:#6498CC; color:#ffffff; font-size:13px; font-family:나눔고딕; }

.group_list	{ position:relative; margin:0 auto; padding:3px; width:33%; line-height:200%; text-align:left; float:left; }
.line		{ border-top:1px solid #EFEFEF; clear:both; }
.btnsetup	{ vertical-align:middle; cursor:pointer; _cursor /**/:hand; }
.info		{ padding:10px; color:#515151; line-height:160%; }
.fbold		{ color:#FF0000; }
.left-pad1	{ padding-left:20px; cursor:pointer; }
.left-pad2	{ padding-left:50px; cursor:pointer; }
.left-pad3	{ padding-left:80px; cursor:pointer; }
.level_1	{ color:#373737; font-size:15px; color:#4C86BF; font-family:나눔고딕; }
.level_2	{ color:#373737; font-size:12px; }
.level_3	{ color:#A2A2A2; font-size:12px; }
.group_bg1	{ background-color:#FFFFFF; }
.group_bg2	{ background-color:#F7F7F7; }
.msg		{ color:#B2B2B2; }

.grpreg_box	{ margin-bottom:10px; }
.grpreg_box select	{ height:25px; cursor:pointer; }
.grpreg_box input	{ height:19px; padding:3px; }
.grpreg_box input[type=button]	{ height:26px; }

.mdate		{ color:#AAAAAA; text-align:center; }

td a:hover	{ text-decoration:underline; }
td a		{ color:#2A2A2A; font-size:12px; }
</style>
<link rel="stylesheet" href="<?=$g4[path]?>/adm/admin.style.css" type="text/css">
<?
$g4[title] = "지음빌더 레이아웃 구성";
include_once ("./admin.head.php");
include_once ("./zm.lib.php");


$index_exist= read_group(0, "");			//-- 인덱스 정보
$group_1	= read_group(1, "");			//-- 메뉴 그룹
$group_2	= read_group(2, "$g_1_r");		//-- 중분류 정보
$group_3	= read_group(3, "");			//-- 소분류 정보
$member_skin = read_group(99, "");			//-- 회원가입

//-- 회원가입 스킨 정보가 없으면 생성 -----------
$rd_mem	= sql_fetch("select * from $zmb[table_builder_config] where db_level='99'");
if(!$rd_mem[db_recno]) {
	$member_skins	= get_skin_dir("zm.member");			//-- 회원가입 스킨
	$topmenu_skins	= get_skin_dir("zm.topmenu");			//-- Topmenu 스킨
	$bottom_skins	= get_skin_dir("zm.bottom");			//-- Bottom 스킨

	$sql	= "insert into $zmb[table_builder_config] set db_level='99', db_menu_reg='1', db_group_name='회원가입', db_group_explain='회원가입', db_layout_skin='$member_skins[0]', db_datetime='".date("Y-m-d H:i:s")."'";
	sql_query($sql);
}


$colspan	= 7;
?>
<div style="clear:both; height:30px;"><?=subtitle("메뉴 구성")?></div>
<form name="group_list">
<table class="grpreg_box">
<tr>
<? if($index_exist[0][recno]) :				//-- INDEX가 있으면 그룹분류 등록 ?>
	<td>&nbsp;&nbsp;&nbsp;
	<!-- 메뉴그룹 등록 -->
		<select name="sel_index_recno">
		<option>INDEX</option>
		</select>→
		<input size=15 name="in_group_1" value="" onKeyPress="if(event.keyCode==13) return false;"> 
	</td>
	<td>
		<input type="button" value="메뉴그룹 등록" class="btn1" onClick="reg_group('1', '<?=$index_exist[0][recno]?>', document.group_list.in_group_1.value)">
	</td>
<? endif; 

   if($group_1[0][recno]) :					//-- 메뉴그룹 있으면 중분류 등록 가능 ?>
	<td>&nbsp;&nbsp;&nbsp;
	<!-- 중분류 등록 -->
		<select name="sel_group_1" onChange="zm_gourl('?g_1_r='+this.value);">
		<option value="">- 메뉴그룹 -</option>
<?	for($i = 0; $i < count($group_1); $i++) : 
		if($g_1_r == $group_1[$i][recno]) $sel_g1 = "selected"; else $sel_g1 = ""; ?>
		<option value="<?=$group_1[$i][recno]?>" <?=$sel_g1?>><?=$group_1[$i][groupname]?></option>
<?	endfor; ?>
		</select> →
		<input size=15 name="in_group_2" value="<?=$g_2_n?>" onKeyPress="if(event.keyCode==13) return false;">
	</td>
	<td>
		<input type="button" value="중분류 등록" class="btn1" onClick="reg_group('2', document.group_list.sel_group_1.value, document.group_list.in_group_2.value)">
	</td>
<? endif; 

   if($group_2[0][recno]) :					//-- 중분류 있으면 중분류 등록 가능 ?>
	<td>&nbsp;&nbsp;&nbsp;
	<!-- 소분류 등록 -->
		<select name="sel_group_2" onChange="zm_gourl('?g_1_r=<?=$g_1_r?>&g_2_r='+this.value);">
		<option value="">- 중분류 -</option>
<?	for($i = 0; $i < count($group_2); $i++) :
		if($g_2_r == $group_2[$i][recno]) $sel_g2 = "selected"; else $sel_g2 = ""; ?>
		<option value="<?=$group_2[$i][recno]?>" <?=$sel_g2?>><?=$group_2[$i][groupname]?></option>
<?	endfor; ?>
		</select> →
		<input size=15 name="in_group_3" value="" onKeyPress="if(event.keyCode==13) return false;"> 
	</td>
	<td>
		<input type="button" value="소분류 등록" class="btn1" onClick="reg_group('3', document.group_list.sel_group_2.value, document.group_list.in_group_3.value)">
	</td>
<? endif; 

   if(!$index_exist[0][recno]) :									//-- INDEX가 없으면 등록 ?>
	<td>&nbsp;&nbsp;&nbsp;
		<input size=15 name="in_group" value="INDEX" readonly> 
		<input type="button" value="등록" class="btn1" onClick="reg_group('0', '', document.group_list.in_group.value)">
	</td>
<? endif; ?>
</tr>
</table>

<table width=100% cellpadding=0 cellspacing=0 border=0 align="center">
<colgroup width=30%>
<colgroup width=28%>
<colgroup width=10%>
<colgroup width=8%>
<colgroup width=6%>
<colgroup width=8%>
<colgroup width=10%>
<tr><td colspan='<?=$colspan?>' class='line2'></td></tr>
<tr class='trhead ht center '>
    <td>INDEX > 메뉴그룹 > 중분류 > 소분류</td>
	<td>스킨 / PAGE / URL</td>
	<td>게시판</td>
	<td>출력순위</td>
	<td>더보기</td>
	<td>Sub domain</td>
	<td>수정일</td>
</tr>
<tr><td colspan='<?=$colspan?>' class='line1'></td></tr>
<tr class='ht'>
	<td>
		<img src="<?=$member_skin[0][btnimage]?>" class="btnsetup" onClick="zm_gourl('./zm.builder_write.php?recno=<?=$member_skin[0][recno]?>');"> 회원가입
	</td>
	<td><a href="<?=$member_skin[0][go_href]?>" target="_blank"><span class="msg">skin/zm.member/</span><?=$member_skin[0][layout_skin]?></a></td>
	<td></td>
	<td></td>
	<td></td>
	<td></td>
	<td class="mdate"><?=$index_exist[0][datetime]?></td>
</tr>
<tr><td colspan='<?=$colspan?>' class='line2'></td></tr>
<tr class='ht'>
	<td>
<?	if($index_exist[0][recno]) : ?>
		<img src="<?=$index_exist[0][btnimage]?>" class="btnsetup" onClick="zm_gourl('./zm.builder_write.php?recno=<?=$index_exist[0][recno]?>');"> INDEX
<?	else : ?>
		<center>INDEX를 등록하세요.</center>
<?	endif; ?>
	</td>
	<td><a href="<?=$index_exist[0][go_href]?>" target="_blank"><span class="msg"><?=$index_exist[0][skin_dir]?></span><?=$index_exist[0][index_skin]?></a></td>
	<td><?=$index_exist[0][board]?></td>
	<td align="left">0</td>
	<td align="center"></td>
	<td></td>
	<td class="mdate"><?=$index_exist[0][datetime]?></td>
</tr>
<tr><td colspan='<?=$colspan?>' class='line2'></td></tr>
<!-- 메뉴그룹 -->
<? for($i = 0; $i < count($group_1); $i++) : ?>
<tr class='ht <?=($i%2)?"group_bg1":"group_bg2"?>' onMouseOver="this.style.backgroundColor='#FFFFE0'" onMouseOut="this.style.backgroundColor=''">
	<td class="left-pad1" onClick="zm_gourl('./zm.builder_write.php?recno=<?=$group_1[$i][recno]?>');">
	<span>└&nbsp;<img src="<?=$group_1[$i][btnimage]?>" class="btnsetup"></span>
	<span class="<?=($g_1_r == $group_1[$i][recno])?"fbold":"level_1"?>"><font color="<?=($group_1[$i][more])?"#6E6E6E":""?>"><?=$group_1[$i][groupname]?></font></span>
	</td>
	<td><a href="<?=$group_1[$i][go_href]?>" target="_blank"><span class="msg"><?=$group_1[$i][skin_dir]?></span><?=$group_1[$i][skin_url]?></a></td>
	<td><?=$group_1[$i][board]?></td>
	<td align="left"><?=$group_1[$i][rank]?></td>
	<td align="center"><?=($group_1[$i][more])?"√":""?></td>
	<td><?=$group_1[$i][subdomain]?> <? if($group_1[$i][subdomain] && $group_1[$i][href]) : ?><a href="<?=$group_1[$i][go_href]?>" target="_blank" title="<?=$group_1[$i][go_href]?>"><img src="./img/icon_preview.gif" align="absmiddle"></a><? endif; ?></td>
	<td class="mdate"><?=$group_1[$i][datetime]?></td>
</tr>
	<!-- 중분류 -->
<?	$group_2_	= read_group("2", $group_1[$i][recno]);
	for($j = 0; $j < count($group_2_); $j++) : ?>
	<tr class='ht <?=($i%2)?"group_bg1":"group_bg2"?>' onMouseOver="this.style.backgroundColor='#FFFFE0'" onMouseOut="this.style.backgroundColor=''">
		<td class="left-pad2" onClick="zm_gourl('./zm.builder_write.php?recno=<?=$group_2_[$j][recno]?>');">
		<span>└&nbsp;<img src="<?=$group_2_[$j][btnimage]?>" class="btnsetup"></span>
		<span class="<?=($g_2_r == $group_2_[$j][recno])?"fbold":"level_2"?>"><?=$group_2_[$j][groupname]?></span>
		</td>
		<td><a href="<?=$group_2_[$j][go_href]?>" target="_blank"><span class="msg"><?=$group_2_[$j][skin_dir]?></span><?=$group_2_[$j][skin_url]?></a></td>
		<td><?=$group_2_[$j][board]?></td>
		<td align="center"><?=$group_2_[$j][rank]?></td>
		<td align="center"><?=($group_2_[$j][more])?"√":""?></td>
		<td><span class="msg"><?=$group_2_[$j][subdomain]?></span></td>
		<td class="mdate"><?=$group_2_[$j][datetime]?></td>
	</tr>
		<!-- 소분류 -->
<?		$group_3_	= read_group("3", $group_2_[$j][recno]);
		for($k = 0; $k < count($group_3_); $k++) : ?>
		<tr class='ht <?=($i%2)?"group_bg1":"group_bg2"?>' onMouseOver="this.style.backgroundColor='#FFFFE0'" onMouseOut="this.style.backgroundColor=''">
			<td class="left-pad3" onClick="zm_gourl('./zm.builder_write.php?recno=<?=$group_3_[$k][recno]?>');">
			<span>└&nbsp;<img src="<?=$group_3_[$k][btnimage]?>" class="btnsetup"></span>
			<span class="<?=($g_3_r == $group_3_[$k][recno])?"fbold":"level_3"?>"><?=$group_3_[$k][groupname]?></span>
			</td>
			<td><a href="<?=$group_3_[$k][go_href]?>" target="_blank"><span class="msg"><?=$group_3_[$k][skin_dir]?></span><?=$group_3_[$k][skin_url]?></a></td>
			<td><?=$group_3_[$k][board]?></td>
			<td align="right"><?=$group_3_[$k][rank]?></td>
			<td align="center"><?=($group_3_[$k][more])?"√":""?></td>
			<td><span class="msg"><?=$group_3_[$k][subdomain]?></span></td>
			<td class="mdate"><?=$group_3_[$k][datetime]?></td>
		</tr>
<?		endfor; //-- 소분류 ?>
<?	endfor; //-- 중분류 ?>
<tr><td colspan='<?=$colspan?>' class='line2'></td></tr>
<? endfor; //-- 메뉴그룹 ?>
</table>
</form>

<div class="info">아이콘이 <img src="./img/btn_setup.gif" class="btnsetup">이면 스킨이나 메뉴 셋업 정보가 정상적으로 설정 되었습니다.<br>
아이콘이 <img src="./img/btn_setup_on.gif" class="btnsetup">이면 스킨이나 연결 주소 등 필요한 정보가 부족해 추가 설정이 필요합니다. 아이콘을 클릭하면 설정 할 수 있습니다.<br>
<font color="#2F64C3">- Sub domain은 서버 환경에 따라 지원되지 않을 수 있으니 미리보기 <img src="./img/icon_preview.gif" align="absmiddle">로 확인 하시기 바랍니다.<br>
- 출력순위 : 숫자가 작은 것 부터 출력 되며 숫자가 같을 때는 나중에 등록한 것이 먼저 출력.<br>
- 하나의 메뉴(버튼)에는 하나의 게시판만 연결 할 수 있습니다.</font>
</div>

<form name="form_group" method="post" enctype="multipart/form-data">
<input type="hidden" name="mode" value="save">
<input type="hidden" name="level" value="">
<input type="hidden" name="uprecno" value="">
<input type="hidden" name="group_name" value="">
<input type="hidden" name="group_skin" value="">
</form>


<script language="javascript">
//-- reg_group(등록할 메뉴 레벨, 상위 레벨 레코드 번호, 분류명, 스킨명)
function reg_group(level, uprecno, gname) {
	var f	= document.form_group;

	f.level.value	= level;
	f.uprecno.value	= uprecno;
	f.group_name.value	= gname;

	if(!gname) { alert("분류명을 입력 해 주세요."); return false; }
	if((level != '0') && !uprecno) { alert("상위 분류(메뉴)를 선택해 주세요."); return false; }
	
	f.action		= "./zm.builder_process.php";
	f.submit();
}


</script>
<?
include_once ("./admin.tail.php");
?>
</body>
</html>