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

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

//현재카테고리 정보
$arrInfo = getCategoryInfo(mysql_real_escape_string($_REQUEST["cat_no"]));
//현재카테고리 패쓰
$arrPath = getCategoryPath(mysql_real_escape_string($_REQUEST["cat_no"]));
//카테고리 목록
$arrList = getCategoryList(mysql_real_escape_string($_REQUEST["cat_no"]));

//_DEBUG($arrList);
//DB해제
SetDisConn($dblink);

?>
<div id="admin-container">
	<?
	if(in_array("product_manage", $arrayMyMenu) && (in_array("product_manage",$_SESSION[$_SITE["DOMAIN"]]["ADMIN"]["AUTH"]) || $_SESSION[$_SITE["DOMAIN"]]["ADMIN"]["GRADE"]=="ROOT")){
		include "../product/menu.php";
	}else{
		include "../shop/menu_good.php";
	}
	?>
    <div id="admin-content">
		<h2 class="admin-title">분류 관리</h2>

		<div class="admin-search">
			<form action="category_evn.php" method="post" name="categoryFrm">
			<input type="hidden" name="evnMode" value="createCategory">
			<input type="hidden" name="s_cat_no" value='<?=$arrInfo["list"][0]["cat_no"]?>'>
			<input type="hidden" name="s_category" value='<?=$arrInfo["list"][0]["cat_code"]?>'>
			<input type="hidden" name="s_depth" value='<?=($arrInfo["list"][0]["cat_no"]?$arrInfo["list"][0]["cat_depth"]+1:$arrInfo["list"][0]["cat_depth"])?>'>
			<div class="total">&nbsp;<strong>
			<a href="<?=$_SERVER[PHP_SELF]?>">ROOT</a>
			<?
			if($arrPath['total'] > 0){
				for($i=0; $i < $arrPath['total']; $i++){
			?>
			 > <a href="<?=$_SERVER[PHP_SELF]?>?cat_no=<?=$arrPath['list'][$i]['cat_no']?>"><?=$arrPath['list'][$i]['cat_name']?></a>
			<?
				}
			}
			?>
			</strong>
			</div>
			<div class="keyword">
				<input size="50" type=text name=new_name onBlur="FillField(this)" onFocus="ClearField(this)" value="새로운 카테고리" class="input" /> <input type="image" src="/backoffice/images/btn_add_cat.gif" alt='신규생성' />
			</div>
			</form>
		</div>

		<table class="admin-table-type1">
		  <colgroup>
		  <col width="70" />
		  <col width="70" />
		  <col width="130" />
		  <col width="160" />
		  <col width="*" />
		  <col width="130" />
		  </colgroup>
		  <thead>		  
			<tr>
			  <th>No.</th>
			  <th>하위</th>
			  <th>하위보기</th>
			  <th>UP / DOWN</th>
			  <th>카테고리명</th>
			  <th>관리</th>
			</tr>
		  </thead>
		  <tbody>
		<?
		if($arrList["total"]>0){
			for($i=0; $i<$arrList["total"]; $i++){		
		?>
			<tr>
				<td><?=$arrList["list"][$i][cat_no]?></td>
				<td><?=number_format($arrList["list"][$i][total_sub])?></td>			
				<td><a href="<?=$_SERVER[PHP_SELF]?>?cat_no=<?=$arrList["list"][$i][cat_no]?>"><img src="./images/btn_view.gif" border=0 alt="<?=$arrList["list"][$i][cat_name]?>"></a></td>
				<td><a href="category_evn.php?evnMode=sort_up&cat_no=<?=$arrList["list"][$i][cat_no]?>&s_cat_no=<?=$arrInfo["list"][0]["cat_no"]?>"><img src="/backoffice/images/k_up.gif" alt="UP" /></a> <a href="category_evn.php?evnMode=sort_down&cat_no=<?=$arrList["list"][$i][cat_no]?>&s_cat_no=<?=$arrInfo["list"][0]["cat_no"]?>"><img src="/backoffice/images/k_down.gif" alt="DOWN" /></a></td>
				<td><?=stripslashes($arrList["list"][$i][cat_name])?></td>
				<td><a href="category_info.php?cat_no=<?=$arrList["list"][$i][cat_no]?>"><img src="/backoffice/images/k_modify.gif" alt="수정" /></a> 
				 <a href="category_evn.php?evnMode=deleteCategory&cat_no=<?=$arrList["list"][$i][cat_no]?>&s_cat_no=<?=$arrInfo["list"][0]["cat_no"]?>" onclick="if(confirm('[<?=$arrList["list"][$i][cat_no]?>] 번호 카테고리를 정말 삭제 하시겠습니까?\n\n하위 카테고리는 현재 <?=number_format($arrList["list"][$i][total_sub])?> 개 입니다.\n\n하위 카테고리도 모두 삭제되며 복구되지 않습니다.')){return true;}else{return false;}"><img src="/backoffice/images/k_delete.gif" alt="삭제" /></a></td>
			</tr>
		<?
			}
		}else{
			echo"
			<tr height=100>
				<td colspan=7>카테고리가 존재하지 않습니다.</td>
			</tr>
			";
		}
		?>
		  </tbody>
		</table>

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