<!--#include virtual ="/manager/common/file/board_top.asp" -->
<%'//*************************************************************************************%>
<script type="text/javascript" src="/common/js/02board_code.js"></script>
<%'//*************************************************************************************%>
<!--#include file ="config.asp"-->
<%
Dim a_num
Dim table, idx_field, oreder_filed, Query_Fields, list_data
Dim ct_idx, ct_code, ct_name, ct_ref, ct_depth, ct_chk, ct_wdate, ct_codeno, ct_file

a_num		= InputValue(request( "a_num" ))


'//쓰기권한체크*************************************************************************************
if is_write <> "Y" Then
	back_back "쓰기권한이 없습니다."
End if
'//**************************************************************************************************


'//파라미터정보 *************************************************************************************
ct_idx		= Inputvalue(request("ct_idx"))

'//용도 : 등록/수정시 현재 상위pk(idx)값, 현재단계
If ct_idx = "" then		'//없으면 1단계

	ct_ref			= "0"
	ct_depth		= "1"

	ct_codeno_ref	= "C0;"

Else

	sql = "select ct_depth,ct_codeno from board_code where  ct_idx=" & ct_idx	'//상위idx값을 구한당
	Set rs_2 = dbcon.execute( sql )

	ref_depth	= rs_2("ct_depth")
	ref_codeno	= rs_2("ct_codeno")

	ct_ref			= ct_idx
	ct_depth		= ref_depth + 1		'//상위단계 + 1
	ct_codeno_ref	= ref_codeno

End if


'//echo "<br>현재단계 : " . $ct_depth . "단계";


'//쓰기권한체크*************************************************************************************
if CInt( ct_depth ) > cint(max_depth_option) then
	back_back "최대 "& max_depth_option & " 단계 까지 가능합니다.."
End if

'//**************************************************************************************************

'//테이블 기본 환경설정 ********************************************************************************
table			= "board_code"			'//테이블명
idx_field		= "ct_idx"				'//기본키
oreder_filed	= "ct_code ASC"			'//정렬기준 필드
Query_Fields	= "ct_idx, ct_code, ct_name, ct_ref, ct_depth, ct_chk, ct_wdate, ct_codeno, ct_file"	'//불러올 필드
'//****************************************************************************************************

'//---------------조합 쿼리문------------------------------------
If v_keyword <> "" then
	search_str = " AND " & v_search & " like '%" & v_keyword & "%'"
End if

If ct_idx <> "" then
	search_str2 = " AND ct_ref = '" & ct_idx & "'"
else
	search_str2 = " AND ct_ref = '0'"
End if

Query_OrderBy = " ORDER BY " & oreder_filed
'//---------------------------------------------------------------

'//-----------------------------리스트 출력 쿼리문 생성-----------------------------
sql = "select " & Query_Fields & " from " & table & " WHERE a_num = " & a_num
sql = sql & search_str & search_str2 & Query_OrderBy
'response.write sql
'response.end
Set col = dbcon.execute( sql )

If col.bof Or col.eof Then
	list_data = null
Else
	list_data = col.getrows
End If
Set col = nothing
'//---------------------------------------------------------------------------------

%>

		<!-- 내용영역 -->
		<div id="contents">

			<div id="contents_head"> 
				<div id="contents_title">
					<img src="/manager/img/tit_ic04.gif" width="22" height="21" class="<%=skin%> center" alt="" /> <h1><span>게시판 분류관리</span></h1>
					
				</div>
				<div id="location">
					<a href="/manager/" tabindex="<%=getTabIndex()%>">Home</a> &gt; <a href="/manager/content/02board/list.asp" tabindex="<%=getTabIndex()%>">게시판관리</a> &gt; <a href="/manager/content/02board/write.asp" class="now" tabindex="<%=getTabIndex()%>"><%=is_title_str%></a>
				</div>
			</div>

			<!-- 내용들어가는곳 -->
			<div id="contents_area">

					<h2 class="<%=skin%>">현재분류경로<span class="loc">: <a href="/manager/content/02board/list.asp" tabindex="<%=getTabIndex()%>">게시판리스트</a>  > <strong class="orange"><%=get_bbsname(a_num)%></strong>
					<%
					If ref_codeno <> "" then

						ref_codeno_arr	= Split(ref_codeno, ";")

						for z=1 To ubound(ref_codeno_arr)

							ct_idx_str = replace(ref_codeno_arr(z),"C","")
							ct_idx_str = replace(ct_idx_str,";","")

							
							If ct_idx_str <> "" then
							
								sql = "Select ct_name from board_code where ct_idx=" & ct_idx_str
								Set rs_3 = dbcon.execute( sql )
								If Not( rs_3.bof Or rs_3.eof ) then
									ct_name_str = rs_3("ct_name")
								End if


								If UBound(ref_codeno_arr)-1 = z then
					%>
								> <a href="write.asp?a_num=<%=a_num%>&amp;ct_idx=<%=ct_idx_str%>" tabindex="<%=getTabIndex()%>"><strong class="orange"><%=ct_name_str%></strong></a> 
					<%
								else

									ref_ct_idx_str = ct_idx_str
					%>
								> <a href="write.asp?a_num=<%=a_num%>&amp;ct_idx=<%=ct_idx_str%>" tabindex="<%=getTabIndex()%>"><%=ct_name_str%></a> 
					<%
								End if
							End if
						next
					End if

					%>

					</span></h2>
					
					
					<form id="frm" method="post" enctype="multipart/form-data" action="write_ok.asp?a_num=<%=a_num%>" onsubmit="return w_chk();">
					<div>
						<input type="hidden" name="a_num" value="<%=a_num%>" />
						<input type="hidden" name="ct_ref" value="<%=ct_ref%>" />
						<input type="hidden" name="ct_depth" value="<%=ct_depth%>" />
						<input type="hidden" name="ct_codeno_ref" value="<%=ct_codeno_ref%>" />

					</div>
				
					<div class="write_info">

						<div class="write_form pt7">
							

							<ul>
							<li class="text"><label for="ct_name_i">분류등록</label> :</li>
							
							<li><input type="text" size="25" title="분류 입력" id="ct_name_i" name="ct_name" class="input_box input" onfocus="focus_on1_<%=skin%>(this);" onblur="focus_off1(this);" value="" maxlength="100" tabindex="<%=getTabIndex()%>" /></li>

							<li class="text"><label for="ct_file">이미지</label> :</li>

							<li><input type="file" size="25" title="이미지 등록" id="ct_file" name="ct_file" class="input_box_file" onfocus="focus_on1_<%=skin%>(this);" onblur="focus_off1(this);" value="" maxlength="100" tabindex="<%=getTabIndex()%>" /></li>
							
							<li><select id="ct_chk_i" name="ct_chk" title="분류 사용여부 선택" tabindex="<%=getTabIndex()%>">
								<option value="Y" selected="selected">사용</option>
								<option value="N" >중지</option>
							</select></li>
							
							<li><div id="<%=skin%>_bt"><span class="button"><input type="submit" value="등록" tabindex="<%=getTabIndex()%>" /></span></div></li>
							
							</ul>

							
						</div>

					</div>

					</form>






					
					<form id= "frm_list" action="" enctype="multipart/form-data"  method='post' >
					<div>
						<input type="hidden" id="status" name="status" />
						<input type="hidden" id="ct_chk" name="ct_chk" />
						<input type="hidden" id="ct_idx" name="ct_idx" />
						<input type="hidden" id="ct_ref" name="ct_ref" value="<%=ct_ref%>" />
						<input type="hidden" id="a_num" name="a_num" value="<%=a_num%>" />

						<input type="hidden" id="chk_all" name="chk_all" />


						
					</div>
					
					<fieldset>
						<legend>분류관리 작성/수정</legend>
						<table cellspacing="0" class="bbs_<%=skin%>" summary="사이트에 사용하는 분류를 관리합니다.">
						<caption>분류관리 서식</caption>
						<colgroup>
						<col width="40" />
						<col width="50" />
						<col />
						<col width="250" />
						<col width="70" />
						<col width="50" />
						<col width="50" />
						</colgroup>

						<thead>
						<tr>
							<th scope="col">선택</th>
							<th scope="col">순서</th>
							<th scope="col">분류</th>
							<th scope="col">이미지</th>
							<th scope="col">사용여부</th>
							<th scope="col">수정</th>
							<th scope="col">삭제</th>
						</tr>
						</thead>

						<tbody>




						<%

						If IsNull(list_data) Then
%>
						<tr>
							<td scope="row" class="center"></td>
							<td scope="row" class="center"></td>
							<td scope="row" class="center"></td>
							<td scope="row" class="center"></td>
							<td scope="row" class="center"></td>
							<td scope="row" class="center"></td>
							<td scope="row" class="center"></td>
							<td scope="row" class="center"></td>
						</tr>
<%
						else

							For i = 0 To UBound(list_data, 2)

								'//필드갯수만큼 ($Query_Fields).가지고온다..
								Call arr2Value(Query_Fields, "list_data", i)

								if ct_chk = "Y" then
									ct_chk_str = "<strong>사용</strong>"
								else
									ct_chk_str = "중지"
								End if

						%>
						<tr>
							<td scope="row" class="center"><input type="checkbox" name="chk" value="<%=ct_idx%>" title="해당 분류 선택" tabindex="<%=getTabIndex()%>" /></td>

							<td scope="row" class="center">
								<a href="move.asp?a_num=<%=a_num%>&amp;move=up&amp;ct_idx=<%=ct_idx%>&amp;ct_code=<%=ct_code%>&amp;ct_ref=<%=ct_ref%>" title="순서 위로 이동" tabindex="<%=getTabIndex()%>"><img src="/manager/img/ic_up.gif" width="10" height="9" alt="순서 위로 이동" /></a><a href="move.asp?a_num=<%=a_num%>&amp;move=down&amp;ct_idx=<%=ct_idx%>&amp;ct_code=<%=ct_code%>&amp;ct_ref=<%=ct_ref%>" title="순서 아래로 이동" tabindex="<%=getTabIndex()%>"><img src="/manager/img/ic_down.gif" width="10" height="9" alt="순서 아래로 이동" /></a>
							</td>


							<td scope="row" class="center">
								
								<input type="text" size="30" title="분류 입력" id="ct_name_<%=ct_idx%>" name="ct_name_<%=ct_idx%>" class="input_box" onfocus="focus_on1_<%=skin%>(this);" onblur="focus_off1(this);" value="<%=ct_name%>" maxlength="100" tabindex="<%=getTabIndex()%>" />
							</td>

							<td scope="row" class="left">
								
								<input type="file" size="20" title="이미지 등록" id="ct_file_<%=ct_idx%>" name="ct_file_<%=ct_idx%>" class="input_box_file" onfocus="focus_on1_<%=skin%>(this);" onblur="focus_off1(this);" value="<%=ct_file%>" maxlength="100" tabindex="<%=getTabIndex()%>" />

								<% If ct_file <> "" Then %>
									<br/><div class="vam pt5"><img src = "/data/board_code/<%=ct_file%>" alt="<%=ct_name%>" />&nbsp;<input type='checkbox' name='ct_file_del_<%=ct_idx%>' value='<%=ct_file%>' tabindex="<%=getTabIndex()%>" />삭제</div>
								<% End if%>

								<input type="hidden" id="ct_file_org_<%=ct_idx%>" name="ct_file_org_<%=ct_idx%>" value="<%=ct_file%>" />

							</td>

							<td scope="row" class="center"><%=ct_chk_str%></td>


							<td scope="row" class="center"><input type="button" value="수정" class="ct_bt01" onclick="m_chk(<%=ct_idx%>);" tabindex="<%=getTabIndex()%>" />

							</td>
							<td scope="row" class="center"><input type="button" value="삭제" class="ct_bt01" onclick="return d_chk('delete_ok.asp?a_num=<%=a_num%>&amp;ct_idx=<%=ct_idx%>&amp;ct_ref=<%=ct_ref%>');"  tabindex="<%=getTabIndex()%>" /></td>
							
						</tr>
						
						<%		
							Next
						End if
						%>


						</tbody>
						</table>
					</fieldset>

					<div class="contoll_box2">
						<ul>
						<li><img src="/manager/img/line01.gif" width="36" height="21" alt="" /></li>
						<li class="pt7"><div class="bt01"><a href="javascript:checkAll();" tabindex="<%=getTabIndex()%>"><span>전체 선택/해제</span></a></div><div class="bt01"><a href="javascript:delete2();" tabindex="<%=getTabIndex()%>"><span>선택 분류삭제</span></a></div></li>
						<li class="pt7 pl4"><span class="gray">|</span> &nbsp;선택한 분류 
								<select id="tot_level_chk" name="tot_level_chk" title="선택한 분류 사용여부 선택" tabindex="<%=getTabIndex()%>">
									<option value="Y" selected="selected">사용</option>
									<option value="N" >중지</option>
								</select>으로
						</li>
						<li class="pt7 pl2"><div class="bt01"><a href="javascript:tot_levelchage();" tabindex="<%=getTabIndex()%>"><span>변경</span></a></div><!-- <input type="button" value="변경" class="ct_bt01" onclick="" /> --></li>
						</ul>
					</div>


					</form>

			</div>
			<!-- 내용들어가는곳 -->

		</div>
		<!-- //내용영역 -->

		<form id= "frm_m" method='post' enctype="multipart/form-data" action="">
			<div>
				<input type="hidden" name="ct_name" />
				<input type="hidden" name="ct_file" />
				<input type="hidden" name="ct_file2" />
				<input type="hidden" name="ct_chk" />
				<input type="hidden" name="ct_idx" />
				<input type="hidden" name="ct_ref" />
			</div>
		</form>

<!--#include virtual="/manager/common/file/sub_bottom.asp"-->
