<%

po_pk	= InputValue(request("po_pk"))


' 레코드필드
R_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"
R_tablename_str	= "poll "
R_WHERE_str		= " WHERE po_pk="&po_pk

Call SelectQuery (R_Fields, R_tablename_str, R_WHERE_str)

If po_sdate = "" then

	po_sdate_y = Year(now)
	po_sdate_m = Month(now)
	po_sdate_d = Day(now)

else

	po_sdate_arr	= split(po_sdate,"-")

	po_sdate_y = po_sdate_arr(0)
	po_sdate_m = po_sdate_arr(1)
	po_sdate_d = po_sdate_arr(2)

End if


If po_edate = "" Then
	
	nm = DateAdd("m",1, now)

	po_edate_y = Year(mm)
	po_edate_m = Month(nm)
	po_edate_d = Day(nm)

else

	po_edate_arr	= split(po_edate, "-")

	po_edate_y = po_edate_arr(0)
	po_edate_m = po_edate_arr(1)
	po_edate_d = po_edate_arr(2)

End if


If Len(po_sdate_m)=1 Then po_sdate_m = "0" & po_sdate_m
If Len(po_sdate_d)=1 Then po_sdate_d = "0" & po_sdate_d
If Len(po_edate_m)=1 Then po_edate_m = "0" & po_edate_m
If Len(po_edate_d)=1 Then po_edate_d = "0" & po_edate_d



' 등급별 권한설정 -----------------------------------------------
if session("ss_g_num") = "" then
	g_num = 2 ' 비회원2 , 총관리자 1
else
	g_num = session("ss_g_num")
End if

g_num_str = "["&g_num&"]"

If InStr(po_group, g_num_str)=0 Then 
	Call Back_back("참가권한이 없습니다.")
	response.end
End if
'  -----------------------------------------------






' 테이블 기본 환경설정 ********************************************************************************
table			= "poll_question"	' 테이블명
idx_field		= "poq_idx"			' 기본키
oreder_filed	= "poq_code ASC"	' 정렬기준 필드
Query_Fields	= "poq_idx ,po_pk ,poq_code, poq_topmemo, poq_question, poq_type, poq_multi, poq_chk, poq_bogi1, poq_bogi2, poq_bogi3, poq_bogi4, poq_bogi5, poq_wdate, poq_mdate"	' 불러올 필드
' ****************************************************************************************************

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

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

' -----------------------------리스트 출력 쿼리문 생성-----------------------------
sql = "select "&Query_Fields&" from "&table&" WHERE po_pk = "&po_pk&" AND poq_chk = 'Y' "
sql = sql & search_str & search_str2 & Query_OrderBy
Set Rs = Dbcon.Execute (sql)
If Not rs.eof Then
	vData = rs.getrows()
	vCnt = UBound(vData,2)
Else
	vCnt = -1
End If
rs.close : Set rs = Nothing
' ---------------------------------------------------------------------------------


%>

<!--#include file="../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 id="poll_tit">
		<div class="title_bg">
			<div class="title_bg_02">
				<div class="title">
					<img src="/content/poll/skin1/img/poll_tit_ic.gif" width="62" height="19" alt="설문주제" />
					<%=po_subject%>
				</div>
				<div class="title_content">
					<ul>
					<li>
						<strong>기&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;간</strong>
						: <%=po_sdate_y%>년 <%=po_sdate_m%>월 <%=po_sdate_d%>일 ~  <%=po_edate_y%>년 <%=po_edate_m%>월 <%=po_edate_d%>일
					</li>
					<li>
						<strong>총문항수</strong>
						: <%=total%> 문항
					</li>
					<li>
						<strong>참여자수</strong>
						: <%=po_count%> 명
					</li>
					</ul>
				</div>
			</div>
		</div>
	</div>
	<!-- //설문주제 타이틀 -->


	
	<!-- 리스트 테이블 -->
<%
If vCnt>-1 Then
	zz= 1

	For i=0 To vCnt

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

		If poq_chk ="Y" then
			poq_chk_str = "<strong>사용</strong>"
		else
			poq_chk_str = "중지"
		End If
%>



	<%If poq_type = "1" then ' 객관식일때%>
	<div class="table_bview">
		<fieldset>
		<legend>게시물 리스트</legend>
			<table cellspacing="0">
			<caption>리스트</caption>
				<colgroup>
				<col width="38" />
				<col width="" />
				</colgroup>
			<thead>
				<tr>
					<th scope="col" class="count"><%=zz%></th>
					<th scope="col" class="subject"><%=poq_question%></th>
				</tr>
			</thead>
			<tbody>
				<tr>
					<td></td>
					<td class="content">
						<%

						

						' 문제 참여자수
						' ***************************************************************						
						sql="SELECT count(por_idx) as por_totcnt FROM poll_result WHERE po_pk="&po_pk&" AND poq_idx ="&poq_idx
						Set Rs = Dbcon.Execute (sql)
						por_totcnt = rs("por_totcnt")
						rs.close : Set rs = nothing
						
						' ***************************************************************


						For z=1 To 5
			
							execute("poq_bogi = poq_bogi"&z)

							If poq_bogi <> "" then ' 있을때



							' 보기별 참여자수
							' ***************************************************************							
							sql="SELECT count(por_idx) as por_cnt FROM poll_result WHERE po_pk="&po_pk&" AND poq_idx ="&poq_idx&" AND por_result='"&z&"'"
							Set Rs = Dbcon.Execute (sql)
							por_cnt = rs("por_cnt")
							rs.close : Set rs = nothing
							' ***************************************************************

							If por_totcnt <> 0 Then ' 참가인원이 있으면

								v_percent = int((((por_cnt/por_totcnt)*100)+0.005)*100)/100 ' 선택한보기 백분율

							else

								v_percent = 0
							End if


							If v_percent = 0 then
								v_percent_str	 = v_percent + 1
							else
								v_percent_str	 = v_percent
							End if


						%>

						<div class="total_result">
							<div class="result01"><%=poq_bogi%></div>
							<div class="result02"><%=por_cnt%>명 </div>
							<div class="result03"><%=v_percent%>%</div>
							<div class="result04">
								<div class="graph0<%=z%>" style="width:<%=v_percent_str%>%;">
									<span/>
								</div>
							</div>
							<div class="clear"/>
						</div>

						<%
							End if

						next
						%>

					</td>
				</tr>
			</tbody>
			</table>
		</fieldset>
	</div>
	<%else ' 주관식일때.%>
	<div class="table_bwrite">
		<fieldset>
		<legend>게시물 리스트</legend>
			<table cellspacing="0">
			<caption>리스트</caption>
				<colgroup>
				<col width="38" />
				<col width="" />
				<col width="70" />
				</colgroup>
			<thead>
				<tr>
					<th scope="col" class="count"><%=zz%></th>
					<th scope="col" class="subject"><%=poq_question%></th>
					<th scope="col" style="padding:0;"><a href="#total" onclick="win_popup3(<%=zz%>,<%=poq_idx%>,'yes','no','no','no',600,500);"><img src="/content/poll/skin1/img/total_bt.gif" width="55" height="18" alt="전체보기" /></a></th>
				</tr>
			</thead>
			<tbody>
				<tr>
					<td></td>
					<td class="content" colspan="2" style="height:15px;">
					</td>
				</tr>
			</tbody>
			</table>
		</fieldset>
	</div>
	<%End if%>





<%
		zz = zz + 1
	Next

End If

%>


	
	<!-- //리스트 테이블 -->
	


	<!-- 버튼 -->
	<div class="poll_button2">
		<span><a href="list.asp?<%=page_info%>" title="목록" tabindex="<%' =getTabIndex()%>" ><img src="/content/poll/skin1/img/list_bt.gif" width="62" height="23" alt="목록" /></a></span>
	</div>
	<!-- //버튼 -->

	

<script type="text/javascript">//<![CDATA[
	
		//새창
	function win_popup3(sun,idx,vscrollbars,vtoolbar,vmenubar,vlocation,vwidth,vheight){	
		window.open('/content/poll/view.asp?sun='+sun+'&poq_idx='+idx,'','scrollbars='+vscrollbars+',toolbar='+vtoolbar+',menubar='+vmenubar+',location='+vlocation+',width='+vwidth+',height='+vheight+',location=no');
	}

	//]]>
	</script>

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

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