<%
Dim is_tablename, R_Fields, R_Fields_no
Dim b_num, b_type, b_id, b_name, b_pwd, b_subject, b_email, b_jumin, b_phone1, b_phone2, b_phone3, b_cate, b_catename, b_noticechk, b_content, b_ip, b_count, b_look, b_open, b_ref, b_step, b_level, b_regdate, b_chuchun, b_sbjclr, b_sdate, b_edate, b_temp1, b_temp2, b_temp3, b_temp4, b_file1, b_file2, b_file3, b_file4, b_file5,b_c_count, b_zip1, b_zip2, b_addr1, b_addr2

'//****************파라미터정보***************************
If a_ad_cms = "Y" then
	a_ad_cms_url = "ad_cms.asp?a_num=" & a_num & "&amp;" & page_info
Else
	a_ad_cms_url = "#"
End if
'//*******************************************************

'//****************페이징정보*****************************
v_pagesize		= a_displaysu		'//리스트 화면에 보여줄 갯수
v_block			= 10				'//페이징 갯수
length			= 30				'//내용 길이
'//*******************************************************

'//****************테이블 기본 환경설정*******************
is_tablename = a_tablename		'//테이블명

R_Fields = "b_num, b_type, b_id, b_name, b_pwd, b_subject, b_email, b_jumin, b_phone1, b_phone2, b_phone3, b_cate, b_catename, b_noticechk, b_content, b_ip, b_count, b_look, b_open, b_ref, b_step, b_level, b_regdate, b_chuchun, b_sbjclr, b_sdate, b_edate, b_temp1, b_temp2, b_temp3, b_temp4, b_file1, b_file2, b_file3, b_file4, b_file5,b_c_count, b_zip1, b_zip2, b_addr1, b_addr2"		'//레코드필드

pk_Field = "b_num"

opt_where_str = ""		'//기본조건이 있을때 사용..없으면 '' 처리

'orderby_str = " ORDER BY "&pk_Field&" DESC "		'//정렬
orderby_str = " ORDER BY b_ref desc, b_step asc "	'//정렬
'//*******************************************************


'//****************옵션 부분******************************
if trim(v_keyword) <> "" and v_search <> "" then	'//검색어가 있다면
	search_str = " AND " & v_search & " like '%" & replace(v_keyword,"'","''") & "%'"
End if

If is_ad_cms <> "Y" then		'//관리자가아닐때 실행할것들...

	if a_member = "Y" then		'//회원제 사용일때
'		search_str2 = " AND b_id = '" & SESSION("ss_m_id") & "' "

		If SESSION("ss_m_jumin")<>"" Then
			search_str2 = " AND ( ( b_jumin = '" & SESSION("ss_m_jumin") & "' and b_jumin <> '' ) or ( b_id = '" & SESSION("ss_m_id") & "' and b_id <> '' ) )  "
		Else
			search_str2 = " AND b_id = '" & SESSION("ss_m_id") & "' "
		End if


'		if SESSION("ss_m_id") = "" then
		if SESSION("ss_m_jumin") = "" And SESSION("ss_m_id") = "" then
			'Call goMessage_board("로그인 후 사용하세요", "/content/board/manager.asp?a_num="&a_num , "", "", a_num)
		End if
	End if
	search_str5 = " AND b_look = 'Y' "

End if


if a_reply = "N" or (a_reply = "Y" and a_replyOpt = "2") then	'//답변기능을 사용하지 않을때.
	search_str3 =" and  b_type = 'N' "
End if


'//기간설정 사용시..
if a_date_list = "Y" then

	If a_sdate <> "" And a_edate = "" then
		search_str4 = " and left(b_regdate,10) >= '" & a_sdate & "' "
	ElseIf a_sdate <>  "" And a_edate <> "" then
		search_str4 = " and left(b_regdate,10) >= '" & a_sdate & "' and left(b_regdate,10) <= '" & a_edate & "'"
	End if
End if

'//분류기능 사용시..
if a_cate = "Y" and v_cate <> "" then
	search_str6 = " AND  b_cate = " & v_cate
End if
'//*******************************************************

'//****************전체 레코드 수 뽑기********************
SQL_T = "select count(" & pk_Field & ") as " & pk_Field & " from " & is_tablename & " where b_noticechk = ''"
SQL_T = SQL_T & search_str & search_str2 & search_str3 & search_str4 & search_str5 & search_str6	'//검색옵션
Set row = dbcon.execute( sql_t )

recordcount = row(pk_Field)
v_totalpage		= fix( (recordcount-1)/ v_pagesize)+1			'전체덩어리갯수 


If v_page = "" then
	v_page = 1
ElseIf v_page < 1 then
	v_page = 1
ElseIf Int(v_page) > v_totalpage then
	v_page = v_totalpage
End If





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

strSQL = "select Top " & v_pagesize & " " & R_Fields & " from " & is_tablename & " where b_noticechk = ''"
strSQL = strSQL & search_str & search_str2 & search_str3 & search_str4 & search_str5 & search_str6	'검색옵션

strSQL = strSQL & " and " & pk_Field & " not in"
strSQL = strSQL & "(select top " & ( v_pagesize * (v_page - 1) ) & " " & pk_Field & " from " & is_tablename & " where b_noticechk = '' " & search_str & search_str2 & search_str3 & search_str4 & search_str5 & search_str6
strSQL = strSQL & " " & orderby_str & ")" & orderby_str

'response.write strSQL
'response.end
Set rs = dbcon.execute( strSQL )
If rs.bof Or rs.eof Then
	list_data = null
Else
	list_data = rs.getrows
End if
Set rs = nothing

%>
<!--#include virtual="/content/board/top.asp"-->

<!-- 리스트 -->
<div id="board" style="width:<%=a_width%>;">

	<div class="board_total">
		<div class="board_total_left">
			<% If a_ad_cms = "Y" then%>
			
				<%If SESSION("ss_m_id") = "" then%>
				<a href="manager.asp?a_num=<%=a_num%>"><img src="/content/board/nninc_simple/img/key.gif" alt="" /></a> 
				<%else%>
				<a href="logout.asp?a_num=<%=a_num%>"><img src="/content/board/nninc_simple/img/unkey.gif" alt="" /></a> 
				<%End if%>
			
			
				전체 <strong><%=recordcount%></strong>개 (페이지 <strong class="board_orange"><%=v_page%></strong>/<%=v_totalpage%>)

			<%else%>
			<img src="/content/board/nninc_simple/img/total_ic.gif" alt="" /> 전체 <strong><%=recordcount%></strong>개 (페이지 <strong class="board_orange"><%=v_page%></strong>/<%=v_totalpage%>)
			<%End if%>


		</div>
		<div class="board_total_right">
			<!-- #include virtual="/content/board/code.asp"-->
		</div>
	</div>



	<%If is_ad_cms = "Y" then%>
	<form id= "frm_list" method='post'>
	<div>
		<input type="hidden" name="status" value=""/>
		<input type="hidden" name="a_num" value="<%=a_num%>" />

		<input type="hidden" id="chk_all" name="chk_all" /><!-- 전체체크 사용하려구.. -->
	</div>
	<%End if%>
	
	
<% colCnt = 2 '기본 th 갯수 %>

	<!-- 리스트 테이블 -->
	<div class="table_blist">
			<table cellspacing="0" >
			<caption><%=replace( tit_name, " | ", "")%></caption>
				<colgroup>
				<%If is_ad_cms = "Y" then	'//관리권한이 있을때만 보인다%>
				<col width="50" />
				<%	colCnt = colCnt+1
				End if%>
				<col width="50" />
				<col width="300" />
				<%If a_lt_a = "Y" then %>
				<col width="60" />
				<% colCnt = colCnt+1
				End if%>
				<%If a_lt_b = "Y" then %>
				<col width="70" />
				<% colCnt = colCnt+1
				End if%>
				<%If a_lt_c = "Y" then %>
				<col width="50" />
				<% colCnt = colCnt+1
				End if%>
				</colgroup>
			<thead>
				<tr>
					<%If is_ad_cms = "Y" then	'//관리권한이 있을때만 보인다%>
					<th scope="col">선택</th>
					<%End if%>
					<th scope="col">번호</th>
					<th scope="col">제목</th>
					<%If a_lt_a = "Y" then %>
					<th scope="col">글쓴이</th>
					<%End if%>

					<%If a_lt_b = "Y" then %>
					<th scope="col">등록일</th>
					<%End if%>
					<%If a_lt_c = "Y" then %>
					<th scope="col" class="th_none">조회</th>
					<%End if%>
				</tr>
			</thead>
			<tbody>
				<!-- 공지기능 -->

				<%

					R_Fields_no = "b_num, b_type, b_id, b_name, b_pwd, b_subject, b_email, b_jumin, b_phone1, b_phone2, b_phone3, b_cate, b_catename, b_noticechk, b_content, b_ip, b_count, b_look, b_open, b_ref, b_step, b_level, b_regdate, b_chuchun, b_sbjclr, b_sdate, b_edate, b_temp1, b_temp2, b_temp3, b_temp4, b_file1, b_file2, b_file3, b_file4, b_file5,b_c_count"	'//레코드필드

					'sql = "SELECT " & R_Fields_no & " FROM " & a_tablename & " WHERE b_noticechk='Y' ORDER BY b_num DESC"
					sql = "SELECT " & R_Fields_no & " FROM " & a_tablename & " WHERE b_noticechk='Y'"
					'//분류기능 사용시..
					if a_cate = "Y" and v_cate <> "" then
						sql = sql & " AND  b_cate = " & v_cate
					End if
					sql = sql & " ORDER BY b_regdate DESC"
					Set col = dbcon.execute( sql )
					If col.bof Or col.eof Then
						notice_data = Null
						notice_chk = false
					Else
						notice_data = col.getrows
						notice_chk = true
					End if
					Set col = Nothing
					
					If Not( IsNull( notice_data ) ) then
						For i = 0 To UBound(notice_data , 2)

							Call arr2Value(R_Fields_no, "notice_data", i)

							'//댓글사용시
							If a_command = "Y" then
								if no_b_c_count <> "0" then
									a_command_str = "(" & no_b_c_count & ")"
								Else
									a_command_str = ""
								End if
							Else
								a_command_str = ""
							End if

				%>

					<tr>
					<%If is_ad_cms = "Y" then	'//관리권한이 있을때만 보인다%>
					<td class="notice"><input type="checkbox" name="chk" value="<%=b_num%>" title="해당 게시글 선택"  /></td>
					<%End if%>
					<td class="notice"><img src="/content/board/nninc_simple/img/notice_ic.gif" width="27" height="16" alt="공지" /></td>
					<td  class="notice title">
							<%If b_type="N" And a_cate = "Y" then response.write "<span class='category_color'>" & b_cate_str(b_cate) & "</span>"%>
							<a href="view.asp?a_num=<%=a_num%>&amp;b_num=<%=b_num%>&amp;<%=page_info%>"><%=b_subject%></a>
							<span class="reply_count"><%=a_command_str%></span>
							<%=get_newimg2(left( b_regdate, 10), a_new)%>
							<%=file_str%>

							
					</td>
					
					<%If a_lt_a = "Y" then %>
					<td class="notice"><%=b_name%></td>
					<%End if%>

					<%If a_lt_b = "Y" then %>
					<td class="notice"><%=replace( CDate(left(b_regdate,10)), "-", ".")%></td>
					<%End if%>
					
					<%If a_lt_c = "Y" then %>
					<td class="notice"><%=b_count%></td>
					<%End if%>
				</tr>
				<%
						Next
					End if
				%>

				<!-- //공지기능 -->

				<%
				If IsNull( list_data ) then			'//------ 내용이 있으면 리스트 출력
					If Not notice_chk then
				%>
				<tr>
					<td class="center" colspan="<%=colCnt%>">등록된 내용이 없습니다.</td>
				</tr>
				<%
					End if
				Else

					If v_page = 1 then
						num = recordcount
					else
						num = recordcount - ((v_page -1) * v_pagesize)
					End if

					For i = 0 To UBound(list_data, 2)

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

						'//첨부파일표시
						If a_upload = "Y" and a_lt_e = "Y" then

							If b_file1 <> "" Or b_file2 <> "" Or b_file3 <> "" Or b_file4 <> "" Or b_file5 <> "" then
								file_str = "<img src='/content/board/nninc_simple/img/icon_file.gif' alt='첨부파일' />"
							Else
								file_str = ""
							End if

						End if
						
						
						'//답변표시
						If b_type = "R" then

							b_type_str = ""		'//초기화
							
							For xx=1 To b_level

								If xx <> 1 Then b_type_str = b_type_str & "&nbsp;&nbsp;&nbsp;"
							next
							
							b_type_str = b_type_str & "<img src='/content/board/nninc_simple/img/reply_ic.gif' width='40' height='16' alt='' />"

						Else
							b_type_str = ""
						End if

						
						'//공개/비공개
						If a_type = "Y" Or a_type = "T" then		'//사용하면

							If b_open = "N" Or a_type = "T" then	'//비공개이면
								b_open_str = "<img src='/content/board/nninc_simple/img/icon_key.gif' width='17' height='12' alt='비밀글' />"
							else					'//공개이면
								b_open_str = ""
							End if

						Else
							b_open_str = ""
						End if

						

						'//사용/중지
						If b_look = "Y" then
							tr_clr = ""
							tr_clr2=""
						ElseIf b_look = "N" then
							tr_clr = " class=""data_none"""
							tr_clr2 = " data_none"
							
						End if
						
						'//댓글사용시
						If a_command = "Y" then
							if b_c_count <> "0" then
								a_command_str = "(" & b_c_count & ")"
							Else
								a_command_str = ""
							End if
						Else
							a_command_str = ""
						End if

				%>
				<tr>
					<%If is_ad_cms = "Y" then		'//관리권한이 있을때만 보인다%>
					<td<%=tr_clr%>><input type="checkbox" name="chk" value="<%=b_num%>" title="해당 게시글 선택"  /></td>
					<%End if%>
					<td<%=tr_clr%>><%=num%></td>
					<td class="title<%=tr_clr2%>">
							<%=b_type_str%>
							
							<%If b_type="N" And a_cate = "Y" then response.write "<span class='category_color'>" & b_cate_str(b_cate) & "</span>"%>
							<a href="view.asp?a_num=<%=a_num%>&amp;b_num=<%=b_num%>&amp;<%=page_info%>"><%=b_subject%></a>
							<span class="reply_count"><?=$a_command_str?></span>
							<%=get_newimg2(left(b_regdate,10), a_new)%>
							<%=file_str%>
							<%=b_open_str%>

					</td>
					
					<%If a_lt_a = "Y" then %>
					<td<%=tr_clr%>><%=b_name%></td>
					<%End if%>

					<%If a_lt_b = "Y" then%>
					<td<%=tr_clr%>><%=replace(CDate(left(b_regdate,10)), "-", ".")%></td>
					<%End if%>
					
					<%If a_lt_c = "Y" then %>
					<td<%=tr_clr%>><%=b_count%></td>
					<%End if%>
				</tr>
				<%
					num = num -1
					next

				End if
				%>

			</tbody>
			</table>
	</div>
	<!-- //리스트 테이블 -->
	



	<!-- 버튼 -->
	<div class="board_button">
		<%If is_ad_cms = "Y" then	'//관리권한이 있을때만 보인다%>
		<div class="fl">
			<ul>
			<li class="pl"><img src="/manager/img/line01.gif" width="36" height="21" alt="" /></li>
			<li class="pt"><div class="board_bt01"><a href="javascript:checkAll();" ><span>전체 선택/해제</span></a></div><div class="board_bt01"><a href="javascript:delete2();" ><span>선택 게시글삭제</span></a></div><div class="board_bt01"><a href="javascript:bmove();" ><span>선택 게시글이동</span></a></div></li>

			<li class="pt7 pl4"><span class="gray">|</span> &nbsp;
				<select id="tot_level_chk" name="tot_level_chk" title="선택한 데이터 사용여부 선택">
					<option value="Y" selected="selected">사용</option>
					<option value="N">중지</option>
				</select>으로
			</li>
			<li class="pt7 pl2"><div class="board_bt01"><a href="javascript:tot_levelchage('<%=page_info%>');" ><span>변경</span></a></div></li>

			</ul>
		</div>
		<%End if%>
		<div class="fr">
			<span class="bt"><a href="list.asp?a_num=<%=a_num%>"><img src="/content/board/nninc_simple/img/list_bt.gif" width="62" height="23" alt="목록" /></a></span>
			<%If is_write = "Y" then%>
			<span class="bt"><a href="write.asp?a_num=<%=a_num%>" ><img src="/content/board/nninc_simple/img/write_bt.gif" width="62" height="23" alt="쓰기" /></a></span>
			<%End if%>
		</div>

	</div>
	
	<!-- //버튼 -->
	<%If is_ad_cms = "Y" then%>
	</form>
	<%End if%>


	<!-- 페이징 -->
	<div class="board_paginate">
		<%page2("list.asp?a_num=" & a_num)%>
	</div>
	<!-- //페이징 -->

	<!-- 게시물 검색 -->
	<div class="board_search">
		<form id="frm_sch" action="list.asp?a_num=<%=a_num%>"  method="post">
			<fieldset>
			<legend>게시물 검색</legend>
			<ul>
			<li class="board_search_start"></li>
			<li><img src="/content/board/nninc_simple/img/search_ic.gif" width="21" height="25" alt="" /></li>
			<li><select id="p_search" name="p_search" title="검색형태 선택" >
				<option value="b_subject" <%=chkSelecT(v_search, "b_subject")%>>제목</option>
				<option value="b_content" <%=chkSelecT(v_search, "b_content")%>>내용</option>
			</select></li>
			<li><input type="text" size="25" title="검색어를 입력하세요" id="p_keyword" name="p_keyword" class="board_input" value="<%=v_keyword%>"  /></li>
			<li><input type="image" src="/content/board/nninc_simple/img/search_bt.gif" id="search_bt" name="search_bt" class="search_bt" alt="검색" /></li>
			<li class="board_search_end"></li>
			</ul>
			</fieldset>
		</form>
	</div>
	<!-- //게시물 검색 -->


</div>
<!-- //리스트 -->
<!--#include virtual="/content/board/bottom.asp"-->