<%

' 테이블 기본 환경설정 ********************************************************************************

table			= "poll"	' 테이블명
idx_field		= "po_idx"		' 기본키
oreder_filed	= "po_wdate desc"	' 정렬기준 필드
Query_Fields	= "po_idx, po_subject, po_group, po_addid, po_sdate, po_edate, po_chk, po_code, po_pk, po_wdate, po_mdate, po_count"	' 불러올 필드
Query_b_Where	= ""	'기본 검색

v_pagesize		= 20				' 목록개수
v_block			= 10				' 페이지개수
' ****************************************************************************************************



' ---------------조합 쿼리문------------------------------------
v_search = inputvalue(request("v_search"))
v_keyword = inputvalue(request("v_keyword"))

If Query_b_Where<>"" Then
	Query_Where = " and " & Query_b_Where	'기본 검색
End If

If v_keyword <> "" then
	Query_Where = Query_Where & " and "&v_search&" like '%"&v_keyword&"%'"
End If

If Query_Where<>"" Then
	Query_Where2 = " WHERE " & Mid(Query_Where,5)
End If

Query_OrderBy = " ORDER BY "&oreder_filed

' ---------------------------------------------------------------



' ---------------------전체 레코드 수 뽑기----------------------------------------
sql = "select count("& idx_field &") as "& idx_field &" from "& table & Query_Where2
Set Rs = Dbcon.Execute (sql)
recordcount = rs(0)	'이 전체레코드갯수를 이용해서 페이지갯수를 뽑아 낼것이다.
rs.close : Set rs = nothing
' ---------------------------------------------------------------------------------


v_totalpage	= int((recordcount-1)/v_pagesize)+1		'전체덩어리갯수 
v_page		= p_page

If v_page = "" then
	v_page = 1
ElseIf v_page < 1 then
	v_page = 1
ElseIf v_page > v_totalpage then
	v_page = v_totalpage
End If


' -----------------------------리스트 출력 쿼리문 생성-----------------------------
strSQL = " SELECT TOP "& v_pagesize &" "& Query_Fields &" FROM "& table &" WHERE "& idx_field &" NOT IN "
strSQL = strSQL & " ( SELECT  TOP "& v_pagesize*(v_page-1) &" "& idx_field &" FROM "& table & Query_Where2 & Query_OrderBy &" ) "
strSQL = strSQL & Query_Where &" "& Query_OrderBy 
Set rs = Dbcon.execute(strSQL)
If Not rs.eof Then
	vData = rs.getrows()
	vCnt = UBound(vData,2)
Else
	vCnt = -1
End If
rs.close : Set rs = Nothing
' ---------------------------------------------------------------------------------

getdate_str = getDateFm(now,4)

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

<script type="text/javascript"> 
	ViewCss('/content/poll/skin1/css/common.css');
</script>
<script type="text/javascript" src="/content/poll/skin1/js/common.js"></script>

<!-- 리스트 -->
<div id="poll">


	<div>
		<input type="hidden" name="status" />
		<input type="hidden" name="a_num" value="<%=a_num%>" />

		<input type="hidden" id="chk_all" name="chk_all" /><!-- 전체체크 사용하려구.. -->
		
	</div>

	<div class="poll_total">
		<div class="poll_total_left">
			<img src="/content/poll/skin1/img/total_ic.gif" width="9" height="8" alt="" /> 전체 <strong><%=recordcount%></strong>개 (페이지 <strong class="poll_orange"><%=v_page%></strong>/<%=v_totalpage%>)
		</div>
		<div class="poll_total_right">
			
		</div>
	</div>

	
	

	<!-- 리스트 테이블 -->
	<div class="table_blist">
		<fieldset>
		<legend>게시물 리스트</legend>
			<table cellspacing="0" summary="게시판명 게시글 정보를 제공하고 제목을 클릭하면 상세내용화면으로 이동됩니다.">
			<caption>리스트</caption>
				<colgroup>
				<col width="60" />
				<col width="" />
				<col width="150" />
				<col width="80" />
				<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" class="th_none">결과</th>
				</tr>
			</thead>
			<tbody>
				
<%
If vCnt>-1 Then


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

	For i=0 To vCnt

		Call arr2Value(Query_Fields, "vData", i)


		If po_edate >= getdate_str and po_sdate <= getdate_str then ' 진행일때..

			po_chk_str2 = "<span class='orange'><strong>진행</strong></span>"			
			link_str = "poll.asp?po_pk="&po_pk&"&amp;"&page_info

		else

			po_chk_str2 = "<strong>종료</strong>"
			link_str = "#end"


		End If


%>

				<tr>
					<td><%=num%></td>
					<td class="title"><a href="<%=link_str%>"><%=po_subject%></a></td>
					<td><%=po_sdate%> ~ <%=po_edate%></td>
					<td><%=po_count%>명</td>
					<td><%=po_chk_str2%></td>
					<td><a href="result.asp?po_pk=<%=po_pk%>&amp;<%=page_info%>"><img src="/content/poll/skin1/img/view_bt.gif" width="24" height="14" alt="보기" /></a></td>
				</tr>


<%
		num = num - 1
	next
Else
%>
				<tr>
					<td></td>
					<td class="title"></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
				</tr>

<%
End if
%>
		
			</tbody>
			</table>
		</fieldset>
	</div>
	<!-- //리스트 테이블 -->
	



	<!-- 버튼 -->
	<div class="poll_button">

	</div>
	<!-- //버튼 -->

	<!-- 페이징 -->
	<div class="poll_paginate">
		<%page("list.asp")%>
	</div>
	<!-- //페이징 -->

	<!-- 게시물 검색 -->
	<div class="poll_search">
		<form id="frm_sch" action="list.asp"  method="post">
			<fieldset>
			<legend>게시물 검색</legend>
			<ul>
			<li class="poll_search_start"></li>
			<li><img src="/content/poll/skin1/img/search_ic.gif" width="21" height="25" alt="" /></li>
			<li><select id="p_search" name="p_search" title="검색형태 선택" tabindex="<%' =getTabIndex()%>">
				<option value="po_subject" <%if v_search = "po_subject" Then resposne.write "selected='selected'" End If %>>제목</option>
				<!-- <option value="b_content" <%if v_search = "b_content" then response.write "selected='selected'" end if %>>내용</option> -->
			</select></li>
			<li><input type="text" size="25" title="검색어를 입력하세요" id="p_keyword" name="p_keyword" class="poll_input" value="<%=v_keyword%>" tabindex="<%=getTabIndex()%>" /></li>
			<li><input type="image" src="/content/poll/skin1/img/search_bt.gif" id="search_bt" name="search_bt" class="search_bt" alt="검색" /></li>
			<li class="poll_search_end"></li>
			</ul>
			</fieldset>
		</form>
	</div>
	<!-- //게시물 검색 -->
	


</div>
<!-- //리스트 -->


<!-- 하단 파일 -->
<!--#include virtual="/content/poll/bottom.asp"-->
