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

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

if ($is_admin != "super")
    alert("최고관리자만 접근 가능합니다.");

$g4['title'] = "그누XE 메뉴관리";
include_once ("$g4[admin_path]/admin.head.php");

$query = "select * from xe_menu where length(code) = '3' order by code asc";
$result = mysql_query($query);
?>
<form method="post" action="xe_menu_list_update.php">
<div class="adm_xe_table_list">
    <table>
        <caption>그누XE 메뉴설정</caption>
        <colgroup>
            <col />
            <col />
            <col />
            <col />
            <col />
        </colgroup>
        <thead>
            <tr>
                <th>메뉴코드</th>
                <th>메뉴이름</th>
                <th>사용여부</th>
                <th>출력순서</th>
                <th>메뉴옵션</th>
            </tr>
        </thead>
		<tfoot>
			<td colspan="6">
				
				<span><input type="submit" value="메뉴설정 변경"></span>
				<span><input type="button" value="메뉴추가" onclick="location.href='./xe_menu_edit.php';"></span>
			</td>
		</tfoot>
        <tbody>
			<?for ($i = 0; $i < $menu = mysql_fetch_array($result); $i++) {//대분류멀티 메뉴?>
			<tr>
				<td>
					<input type="hidden" name="chk[]" value='<?=$menu[code]?>'>
					<?=$menu[code]?>
				</td>
				<td>
					<input type="text" name="ca_name[]" value="<?=$menu[name]?>" style="border:1px solid #FF7575">
				</td>
				<td><?=($menu[visible] == "1")?"사용":"미사용"?></td>
				<td>
					<input type="text" name="order[]" value="<?=$menu[order]?>" style="border:1px solid #FF7575">
				</td>
				<td>
					<input type="button" value="수정" onclick="location.href='./xe_menu_edit.php?code=<?=$menu[code]?>';">&nbsp;
					<input type="button" value="미리보기" onclick="window.open('about:blank').location.href='<?=$g4[path]?><?=$menu[link]?>';">&nbsp;
					<input type="button" value="하위추가" onclick="location.href='./xe_menu_edit.php?add=<?=$menu[code]?>';">&nbsp;
					<input type="button" value="삭제" onclick="if(confirm('해당 메뉴를 삭제하시겠습니까?')){ location.href='./xe_menu_del.php?code=<?=$menu[code]?>'; }">
				</td>
			</tr>
			<? // 대표메뉴가 아닌 서브 메뉴
				$query2 = "select * from xe_menu where length(code) != '3' and code like '$menu[code]%' order by code asc";
				$result2 = mysql_query($query2);
				for ($s = 0; $s < $sub = mysql_fetch_array($result2); $s++) {
					$code_size[$s] = strlen($sub[code])/3;
					
					for ($b = 0; $b < $code_size[$s]; $b++) {
						if($b==0){
							$bar[$s] = "└";
						}else {
							if ($b != "1") {
							$bar[$s] .=  "ㅡ";
							}

						}
					}
			?>
			<tr>
				<td>
					<input type="hidden" name="chk[]" value='<?=$sub[code]?>'>
					<?=$sub[code]?>
				</td>
				<td>
					<?=$bar[$s]?>&nbsp;
					<input type="text" name="ca_name[]" value="<?=$sub[name]?>" style="border:1px solid #7875FF">
				</td>
				<td><?=($sub[visible] == "1")?"사용":"미사용"?></td>
				<td>
					<input type="text" name="order[]" value="<?=$sub[order]?>"style="border:1px solid #7875FF">
				</td>
				<td>
					<input type="button" value="수정" onclick="location.href='./xe_menu_edit.php?code=<?=$sub[code]?>';">&nbsp;
					<input type="button" value="미리보기" onclick="window.open('about:blank').location.href='<?=$g4[path]?><?=$sub[link]?>';">&nbsp;
					<input type="button" value="하위추가" onclick="location.href='./xe_menu_edit.php?add=<?=$sub[code]?>';">&nbsp;
					<input type="button" value="삭제" onclick="if(confirm('해당 메뉴를 삭제하시겠습니까?')){ location.href='./xe_menu_del.php?code=<?=$sub[code]?>'; }">
				</td>
			</tr>
			<?}}?>
        </tbody>
    </table>
</div>
<?
include_once("$g4[admin_path]/admin.tail.php");
?>
