<!-- #include virtual = "/common/lib/dbcon.asp" -->
<!-- #include virtual = "/common/lib/func.asp" -->
<!-- #include virtual = "/content/newsletter/top.asp" -->
<%

v_page    = Request("p_page")
v_search  = Request("p_search")
v_keyword = Request("p_keyword")







'리스트 화면에 보여줄 갯수
v_pagesize = 10
'페이징 갯수
v_block = 10

'내용 길이
length = 30 

If Len(v_page) = 0 Then
	v_page = 1
End If

if (trim(Request("p_keyword")) <> "") and (Request("p_search") <> "") Then  '검색어가 있다면
	strSearch =  "Where  "& v_search &" like '%"& Replace(v_keyword,"'","''")&"%'"
end if




SQg_T = "Select Count(News_idx),CEILING(CAST(Count(*) AS FLOAT)/" & v_pagesize & ") from NewsLatter "
SQg_T = SQg_T & strSearch
Set Rs_Tot = Dbcon.execute(SQg_T)



v_total     = Rs_Tot(0)
v_totalpage = Rs_Tot(1)

strSQL = "SELECT Top "& (v_page*v_pagesize) & " * FROM NewsLatter "
strSQL = strSQL & strSearch
strSQL = strSQL & " Order by News_date Desc"
Set Rs_L = DbCon.Execute(strSQL)

'title_str "뉴스레터목록",600
%>

<body>
<table width="600" cellpadding="0" cellspacing="0">
	<!--<tr>
		<td height=20>&nbsp;</td>
	</tr>
	<tr>
		<td class="htitle"><strong><font color="#D68E4A" size="3">[뉴스레터목록]</font></strong></td>
	</tr>-->
	<tr>
		<td>&nbsp;</td>
	</tr>
	<tr>
		<td align="center">
			<table width=600 align="center" cellpadding="0" cellspacing="0">
				<tr>
					
          <td align="right">전체뉴스레터수 : <%=v_total%> &nbsp;&nbsp;<font color="0062C8"><b><%=v_totalpage%></b></font>&nbsp; 
            / <font color="0062C8"><b><%=v_page%></b></font></td>
				</tr>
			</table>
			<table width="600" border="0" cellspacing="0" cellpadding="0">
			  <tr>
			    <td height="5" bgcolor="DFDEDD"></td>
			  </tr>
		    </table>
			
      <table width=600 align="center" cellpadding="3" cellspacing="1" bgcolor="#D5D5D5">
        <form name="frm" method="post">
		<input type="hidden" name="p_page" value="<%=v_page%>">
        <input type="hidden" name="p_search" value="<%=v_search%>">
        <input type="hidden" name="p_keyword" value="<%=v_keyword%>">
          <tr bgcolor="#F7F7F7" class="td" align="center" height="25"> 
            <td width="31" bgcolor="F5F5F5"><input type=checkbox name=chk_all onClick="javascript:checkAll();"></td>
            <td width="38" bgcolor="F5F5F5"><b>번호</b></td>
            <td width="324" bgcolor="F5F5F5"><b>제목</b></td>
            <td width="99" bgcolor="F5F5F5"><b>발행일</b></td>
            <td width="70" bgcolor="F5F5F5"><b>발송횟수</b></td>
			<td width="70" bgcolor="F5F5F5"><b>발송량</b></td>
          </tr>
          <%    
			If v_totalpage > 0 Then        '------ 내용이 있으면 리스트 출력
				Rs_L.Move (v_page - 1) * v_pagesize

				if v_page = 1 then
					num = v_total
				else 
					num = v_total - ((v_page - 1) *  v_pagesize) 
				end if

'-------------------- 리스트 반복 시작 --------------------
	      Do while not Rs_L.EOF

		       
                    
%>
          <tr height="25" align="center" bgcolor="#FFFFFF"> 
            <td>
			   <div align="center"> 
					<input type=checkbox  name="chk" value="<%=Rs_L("News_idx")%>" >
			    </div>
			</td>
            <td><%=num%></td>
            <td ><a href="view.asp?News_idx=<%=Rs_L("News_idx")%>&p_page=<%=v_page%>&p_search=<%=v_search%>&p_keyword=<%=v_keyword%>"><%=Rs_L("News_subject")%></a></td>
            <td><%=left(Rs_L("News_date"),10)%></td>
            <td><%=Rs_L("News_send")%>회</td>
			<td><%=Rs_L("News_send_qty")%>통</td>
          </tr>
          <%			
				Rs_L.MoveNext
				num = num - 1
				Loop
		else  '게시할 목록이 없다면
%>
          <tr> 
            <td bgcolor="ffffff" height="30" align="center" colspan="10">등록된 뉴스레터가 
              없습니다</td>
          </tr>
          <%
    end If
'-------------------- 리스트 반복 끝 --------------------
%>
        </form>
      </table>
		<!--
		<table width="645" border="0" cellspacing="0" cellpadding="0">
          <tr>  
            <td bgcolor="ECE2F0"  height="5"></td>
          </tr>
        </table>
		-->
		<table width="600" cellpadding="0" cellspacing="0" border=0>
			<tr>
				<td align="center" height=30 colspan="7">
<%
					v_temp = Int((v_page - 1) / v_block) * v_block + 1

					If v_temp = 1 Then
							'Response.Write "[이전 " & v_block & "개]"
					Else 
							Response.Write"<a href=list.asp?p_page="&v_temp-v_block&"&p_search="&v_search&"&p_keyword="&v_keyword&">[이전]</a>"
					End If

					v_loop = 1

					Do Until v_loop > v_block Or v_temp > v_totalpage
							If v_temp = CInt(v_page) Then
									Response.Write "[" & v_temp &"]&nbsp;" 
							Else
									Response.Write"<a href=list.asp?p_page="&v_temp&"&p_search="&v_search&"&p_keyword="&v_keyword&">[" & v_temp & "]</a>&nbsp;"
							End If
							v_temp = v_temp + 1
							v_loop = v_loop + 1
					Loop

					If v_temp > v_totalpage Then
							'Response.Write "[다음 " &v_block&"개]"
					Else
							Response.Write"<a href=list.asp?p_page="&v_temp&"&p_search="&v_search&"&p_keyword="&v_keyword&">[다음]</a>"
					End If
%>
				</td>
			</tr>
			<tr>
			   <td>

				<table width="" cellpadding="0" cellspacing="0" border=0>
				  <tr>
					<td align="center" height=30 onMouseOver="window.status=('뉴스레터을 등록합니다.');return true;" onMouseOut="window.status=(''); return true;">
					  <input type="button" value="만들기" onClick="location.href='write.asp?mode=a';">
					</td>
					<td width=5>&nbsp;</td>
                      
					<td align="center" height=30 onMouseOver="window.status=('뉴스레터을 삭제합니다.');return true;" onMouseOut="window.status=(''); return true;">
					  <input type="button" value="삭제하기" onClick="change_del();">
					</td>
				   </tr>
				</table>

				</td>
             
				<form method='post' action='list.asp'>
				<td align="right" colspan="6">
				<!--
					<select name="p_search" class=select_f>
						<option value='ID' <% if v_search = "ID" then %>selected<% end if %>>아이디</option>
						<option value='Name' <% if v_search = "Name" then %>selected<% end if %>>이름</option>
					</select>
					<input type='text' name="p_keyword" size=20 maxlength=20 value='<%=trim(Request("p_keyword"))%>'>
					<input type='submit' value="검 색" onMouseOver="window.status=('주어진 단어로 검색을 시작합니다.');return true;" onMouseOut="window.status=(''); return true;" >
					-->
				</td>
				</form>
			</tr>
		</table>
		</td>
	</tr>
</table>
<br><br>
</body>
</html>
<%
	Rs_Tot.Close
	Set Rs_Tot = Nothing

	Rs_L.Close
	Set Rs_L = Nothing


	Dbcon.Close
	Set Dbcon = Nothing
%>