<!-- #include virtual="/manager/common/file/member_top.asp"-->
<%'//*************************************************************************************%>
<script type="text/javascript" src="/common/js/03member_div.js"></script>
<%'//*************************************************************************************%>
<!-- #include file= "config.asp"-->
<%
Dim sql, table, idx_field, oreder_filed, Query_Fields, search_str, search_str2, Query_OrderBy
Dim ct_idx, ct_code, ct_name, ct_ref, ct_depth, ct_chk, ct_wdate, ct_codeno, ct_url

'//쓰기권한체크*************************************************************************************
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 member_div 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

	Set rs_2 = nothing
End if

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


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

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

'//테이블 기본 환경설정 ********************************************************************************
table			= "member_div"			'//테이블명
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_url"		'//불러올 필드
'//****************************************************************************************************

'//---------------조합 쿼리문------------------------------------
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 ct_idx <> '0'"
sql = sql & search_str & search_str2 & Query_OrderBy

'response.write sql
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/03member/list.asp" tabindex="<%=getTabIndex()%>">회원/권한관리</a> &gt; <a href="/manager/content/03member/list.asp" tabindex="<%=getTabIndex()%>">회원관리</a> &gt; <a href="/manager/content/03member_div/write.asp" class="now" tabindex="<%=getTabIndex()%>">부서관리</a>
				</div>
			</div>

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

					<h2 class="<%=skin%>">현재메뉴경로<span class="loc">: <a href="write.asp" tabindex="<%=getTabIndex()%>">부서관리홈</a>  

					<%
					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 member_div 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
								Set rs_3 = nothing

								If ubound(ref_codeno_arr)-1 = z then
						%>
								> <a href="write.asp?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?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" action="write_ok.asp" onsubmit="return w_chk();">
					<div>
						<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>
							<%=ct_dept%>
							<%If ct_depth = 1 then%>

							<li><input type="text" size="80" 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>

							<%elseif CInt(ct_depth) <= max_depth_option then%>
							
							<li><input type="text" size="62" 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>
							
							<%End if%>
							<li><select id="ct_chk_i" name="ct_chk" title="부서 사용여부 선택" tabindex="<%=getTabIndex()%>">
								<option value="Y" selected="selected">사용</option>
								<option value="N" >중지</option>
							</select></li>
							<%If CInt(ct_depth) = 1 Then %>
							
							<li><div id="<%=skin%>_bt"><span class="button"><input type="submit" value="등록" tabindex="<%=getTabIndex()%>" /></span></div></li>
							
							<%elseIf ct_depth <= max_depth_option then%>
							<li><div id="<%=skin%>_bt"><span class="button"><input type="submit" value="등록" tabindex="<%=getTabIndex()%>" /></span></div></li>
							<li><div id="w01_bt"><span class="button"><input type="button" value="상위부서 이동" onclick="location.href='write.asp?ct_idx=<%=ref_ct_idx_str%>';" /></span></div></li>
							<%End if%>
							</ul>

							
						</div>

					</div>

					</form>

					
					<form id= "frm_list" action=""  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="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 />
						<%If ct_depth < max_depth_option then%>
						<col width="64" />
						<%End if%>
						<col width="70" />
						<col width="50" />
						<col width="50" />
						</colgroup>

						<thead>
						<tr>
							<th scope="col">선택</th>
							<th scope="col">순서</th>
							<th scope="col">부서</th>
							<%If CInt(ct_depth) < CInt(max_depth_option) then%>
							<th scope="col">하위부서</th>
							<%end if%>
							<th scope="col">사용여부</th>
							<th scope="col">수정</th>
							<th scope="col">삭제</th>
						</tr>
						</thead>

						<tbody>




<%
						'//bbs_list_data
						If IsNull( list_data ) Then
%>
						<tr>
							<td scope="row" class="center"></td>
							<td scope="row" class="center"></td>
							<td scope="row" class="center"></td>
							<%If CInt(ct_depth) < CInt(max_depth_option) then%>
							<td scope="row" class="center"></td>
							<%End if%>
							<td scope="row" class="center"></td>
							<td scope="row" class="center"></td>
							<td scope="row" class="center"></td>
						</tr>
<%
						Else
							For zz = 1 To UBound(list_data, 2)+1
								Call arr2Value( Query_Fields, "list_data", zz-1 )

								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?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?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="58" title="부서 입력" id="ct_name<%=zz%>" name="ct_name<%=zz%>" class="input_box" onfocus="focus_on1_<%=skin%>(this);" onblur="focus_off1(this);" value="<%=ct_name%>" maxlength="100" tabindex="<%=getTabIndex()%>" />
							</td>
							<%If CInt(ct_depth) < CInt(max_depth_option) then%>
							<td scope="row" class="center">
								<input type="button" value="보기" class="ct_bt01" onclick="page_go1('write.asp?ct_idx=<%=ct_idx%>');" tabindex="<%=getTabIndex()%>" />
							</td>
							<%End if%>							
							<td scope="row" class="center"><%=ct_chk_str%></td>
							<td scope="row" class="center"><input type="button" value="수정" class="ct_bt01" onclick="frm_modify<%=zz%>(<%=ct_idx%>,<%=ct_ref%>);" tabindex="<%=getTabIndex()%>" />

								
								<script type="text/javascript">
									function frm_modify<%=zz%>(ct_idx,ct_ref){
										var ct_idx, ct_ref;

										if (CheckSpaces(document.getElementById('frm_list').ct_name<%=zz%>, '부서명')) { return false; }
										//else if (CheckSpaces(document.getElementById('frm').sc_sitename_en, '영문명')) { return false; }

										else {

											loading_st(1);
											document.getElementById('frm_m').ct_name.value	= document.getElementById('frm_list').ct_name<%=zz%>.value;
											//document.getElementById('frm_m').ct_chk.value	= document.getElementById('frm_list').ct_chk<?=$zz?>.value;

											<%If ct_depth = "2" then%>
											document.getElementById('frm_m').ct_url.value	= document.getElementById('frm_list').ct_url<%=zz%>.value;
											<%end if%>
											document.getElementById('frm_m').ct_idx.value	= ct_idx;
											document.getElementById('frm_m').ct_ref.value	= ct_ref;
											document.getElementById('frm_m').action			= "write_ok.asp";
											document.getElementById('frm_m').submit();
										
										}
									}
								</script>
							</td>
							<td scope="row" class="center"><input type="button" value="삭제" class="ct_bt01" onclick="return d_chk('delete_ok.asp?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' action="">
			<div>
				<input type="hidden" name="ct_name" />
				<input type="hidden" name="ct_url" />
				<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"-->