<!--#include virtual="/common/file/inc_head.asp"-->	
<%
dim v_search, v_keyword, table, Query_Fields, Query_Where, Query_OrderBy
Dim recordcount
dim pagesize, v_totalpage, v_page, TotalCnt, v_block

v_search		= inputValue( Request.QueryString("p_search") )		'검색조건
v_keyword		= inputValue( Request.QueryString("p_keyword") )	'검색어
prepage			= Request.ServerVariables("path_info") & "?" & Request.ServerVariables("query_string")	'현재페이지경로

table			= "SDK_MMS_SEND"		'테이블
idx_field		= "MSG_ID"			'기본키
oreder_filed	= "SEND_DATE desc"	'정렬기준 필드
Query_Fields	= "MSG_ID, SEND_DATE, MMS_MSG, DEST_INFO" '불러올 필드
pagesize		= 12				'목록개수
v_block			= 10				'페이지개수
now_date		= Replace( Date(), "-", "" ) & Right("0"&hour(now), 2) & Right("0"&minute(now), 2) & Right("0"&second(now), 2)

'==================조합 쿼리문=======================
If v_keyword <> "" then
	Query_Where = " where schedule_type = 1 and user_id = '" & session("ss_m_id") & "' and send_date >= '"& now_date &"' and " & v_search & " like '%" & v_keyword & "%'"
	andOrWhere	= " and "
Else
	Query_Where = " where schedule_type = 1 and user_id = '" & session("ss_m_id") & "' and send_date >= '"& now_date &"'"
	andOrWhere	= " and "
End if
Query_OrderBy = " ORDER BY "&oreder_filed
'==================조합 쿼리문=======================

'==================전체 레코드 수 뽑기===============
sql="select count(*) from " & table & Query_Where
set rs = DbCon.execute(sql)
recordcount=CInt( rs(0) ) '이 전체레코드갯수를 이용해서 페이지갯수를 뽑아 낼것이다.	
Set rs = nothing
'==================전체 레코드 수 뽑기===============

v_totalpage=fix((recordcount-1)/pagesize)+1 '전체덩어리갯수 
v_page = Request.QueryString("p_page")

if v_page="" then
	v_page = 1
elseif cint(v_page) < 1 then
	v_page = 1
elseif cint(v_page)>cint(v_totalpage) then
	v_page=cint(v_totalpage)
end if

'========================리스트 출력 쿼리문 생성======================
'MS-SQL
sql = "select Top " & pagesize& " " & Query_Fields & " from " & table
sql = sql & Query_Where & andOrWhere & " "&idx_field&" not in"
sql = sql & "(select top " & pagesize * (v_page - 1) & " "&idx_field&" from " & table
sql = sql & Query_Where & Query_OrderBy & ")"
sql = sql & Query_OrderBy
'========================리스트 출력 쿼리문 생성 끝======================
'response.write sql

Set rs = Dbcon.Execute( sql )
If rs.bof Or rs.eof Then
	List_data = Null
	TotalCnt = 0
else
	List_data = rs.getrows
	TotalCnt = recordcount
End if

Set rs = Nothing
DbCon.close
Set DbCon = Nothing

%>

<script type="text/javascript">
//<![CDATA[


function checkAll(){
	var eForm = document.getElementById('log_List');
	if(eForm.chk_all.value == "") {
		eForm.chk_all.value="Y";
		checkboxChk(eForm.MSG_ID, true);
	}else {
		eForm.chk_all.value="";
		checkboxChk(eForm.MSG_ID, false);
	}
}

function checkboxChk(chkObj, type){
	var field = chkObj;//buseo_mem.document.mem_list.check;
	if(field.length == null){
		field.checked = type;
	}else{
		for (i = 0; i < field.length; i++){
			field[i].checked = type;
		}
	}
}

function DelOk(){
	var eForm = document.getElementById("log_List");
	if (confirm("삭제하시겠습니까?")){
		eForm.submit();
	}return;
}

function delCount( num ){
	if(confirm("해당 예약문자를 삭제하시겠습니까?")){
		$("input[name='MSG_ID']").attr("checked", false);
		$("#MSG_ID_"+num).attr("checked", true);
		document.getElementById("log_List").submit();
	}
}

function reSend(num){
	if(confirm("이 메세지를 재발송하시겠습니까?")){
		var eForm = document.getElementById("resendFrm");
		var number = document.getElementById("number_"+num).value;
		var message = document.getElementById("message_"+num).value;
		
		eForm.number.value = number;
		eForm.message.value = message;
		eForm.submit();
	}
}
//]]>
</script>

<!-- 타이틀 -->
<div id="cont_head">
	<h2>예약문자 확인</h2>
</div>
<!-- //타이틀 -->
<!-- 내용 -->
<div id="cont_wrap">
	<!-- 예약문자확인 -->

	<div class="s0102">
		<!-- 탭 -->
		<ul class="con_tab">
			<li><a href="./02_01.asp">단문</a></li>
			<li><a href="#" class="on">장문</a></li>
		</ul>
		<!-- //탭 -->
		<form id="log_List" name="log_List" method="post" action="reserve_del_ok_mms.asp">
		<div>
		<input type="hidden" name="chk_all" value="" />
		<input type="hidden" name="table" value="<%=table%>" />
		</div>
		<ul class="sentlist">
<%
If Not(IsNull(List_data)) then
	For i = 0 To UBound(List_data, 2)
		num = (TotalCnt - pagesize * (v_page - 1)) - i
		Call arr2Value(Query_Fields, "List_data", i)

		write_date = createDate( send_date )
		dest_info_count = 0
		If dest_info <> "" then
			dest_info_arr = Split(dest_info, "|")
			dest_info_count = ubound(dest_info_arr) + 1
		End if
		mms_msg_str = Replace(mms_msg, vbcrlf, "<br />")
		mms_msg_str = Replace(mms_msg_str, "  ", "&nbsp;&nbsp;")
%>
			<li>
				<div class="ct"><%=mms_msg_str%></div>
				<dl class="info">
					<dt>동시발송</dt>
					<dd class="receiver"><%=dest_info_count%>건</dd>
					<dt>예약날짜</dt>
					<dd><%=write_date%></dd>
				</dl>
				<input type="checkbox" id="MSG_ID_<%=num%>" name="MSG_ID" value="<%=MSG_ID%>" class="vam" />
				<textarea style="display:none;" id="message_<%=num%>"><%=mms_msg%></textarea>
				<div class="btngroup">
					<ul class="btn_sm">
						<!-- <li><a href="#resend" onclick="reSend(<%=num%>);" class="sm1">발송</a></li> -->
						<li><a href="#del" onclick="delCount(<%=num%>);" class="sm2">삭제</a></li>
					</ul>
				</div>
			</li>
<%
	Next
Else
End if
%>			
		</ul>
		</form>


		<div class="paginate">
			<%=pageStyle("./02_02.asp")%>
		</div>
		<div class="f_board">
			<div class="btngroup">
				<ul class="btn_nrm_bor column2">
					<li><a href="#chk" onclick="checkAll();">전체선택/해제</a></li>
					<li><a href="#del" onclick="DelOk();">선택삭제</a></li>
				</ul>
			</div>
			<div class="search_frm">
				<ul>
					<li class="s_month">
						&nbsp;
					</li>
					<li class="s_word">
					<form id="frm_sch" action="<%=Request.ServerVariables("path_info")%>"  method="get">
						<select id="p_search" name="p_search" style="width:100px;">
							<option value="MMS_MSG" <%=chkSelect(v_search, "MMS_MSG")%>>내용</option>
							<option value="DEST_INFO" <%=chkSelect(v_search, "DEST_INFO")%>>수신번호</option>
						</select>
						<input type="text" id="p_keyword" name="p_keyword" class="w_text" placeholder="검색어를 입력하세요." value="<%=v_keyword%>" />
						<input type="image" src="/img/sub/btn_search.png" title="검색" class="btn_search" />
					</form>
					</li>
				</ul>
			</div>
		</div>
	</div>

	<!-- //예약문자확인 -->
</div>
<!-- //내용 -->

<form id="resendFrm" method="post" action="/content/01message/01_01.asp">
<input type="hidden" name="number" value="" />
<input type="hidden" name="message" value="" />
</form>

<!--#include virtual="/common/file/bottom.asp"-->