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

Set ST = New SelectTable

'단문 테이블명
stat_date = Year(now) & Right( "0" & Month(now), 2 )
stat_date = "201708"
table_1 = "em_log_" & stat_date

sql = "select count(*) as cnt from information_schema.tables where table_name = '" & table_1 & "'"
table_cnt = ST.selectQueryColumn( sql )
If table_cnt = 0 Then
	table_1 = ""
End if

'장문 테이블명
stat_date = Right(Year(now),2) & Right( "0" & Month(now), 2 )
stat_date = "1708"
table_2 = "sdk_mms_report_detail_" & stat_date
sql = "select count(*) as cnt from information_schema.tables where table_name = '" & table_2 & "'"
table_cnt = ST.selectQueryColumn( sql )
If table_cnt = 0 Then
	table_2 = ""
End if

tmp_select_1 = ""
If table_1 <> "" then
	tmp_select_1 = tmp_select_1 & "	select * from ("
	tmp_select_1 = tmp_select_1 & "		select tran_phone, convert(varchar, tran_date,112)+replace(convert(varchar, tran_date,108), ':', '') as tran_date, '"&table_1&"' as logname, tran_pr as idx"
	tmp_select_1 = tmp_select_1 & "		from " & table_1
	tmp_select_1 = tmp_select_1 & "		where tran_id = '" & session("ss_m_id") & "'"
	tmp_select_1 = tmp_select_1 & "	) tbl_1"
End if

tmp_select_2 = ""
If table_2 <> "" then
	tmp_select_2 = tmp_select_2 & "	select * from ("
	tmp_select_2 = tmp_select_2 & "		select phone_number, send_date, '"&table_2&"' as logname, job_id"
	tmp_select_2 = tmp_select_2 & "		from " & table_2
	tmp_select_2 = tmp_select_2 & "		where user_id = '" & session("ss_m_id") & "'"
	tmp_select_2 = tmp_select_2 & "	) tbl_2"
End if

table = ""
If tmp_select_1 <> "" or tmp_select_2 <> "" Then

	table = table & "("
	table = table & tmp_select_1
	If tmp_select_2 <> "" Then 
		If tmp_select_1 <> "" Then 
			table = table & "	union all"
		End If
		table = table & tmp_select_2
	End if
	table = table & ") tbl3"		'테이블
Else
	Response.write "이달에 발송기록이 없습니다."
	Response.end
End if


sql = "select top 20 tran_phone, tran_date from " & table & " order by tran_date"
'Response.write sql
rs = ST.selectQueryTable( sql )
If isnull(rs) Then
	Response.write "이달에 발송기록이 없습니다."
	Response.end
End if
%>


			<ul class="add_num">
<%
If Not( isnull(rs) ) Then
	For i = 0 To ubound( rs )
		ST.arr2Value( rs(i) )
		tran_phone_str = phoneValue( tran_phone )
%>
				<li><input type="checkbox" id="chk_new_number_<%=i%>" name="chk_new_number"  value="M;noname;<%=tran_phone%>" data-mobile="<%=tran_phone_str%>" data-count="1" /> <label for="chk_new_number_<%=i%>"><%=tran_phone_str%></label> <!-- <a href="#"><img src="/img/sub/btn_delete.gif" alt="삭제" /></a> --></li>
<%
	next
End if
%>
			</ul>
			<!--<div class="paginate">
				<a href="#" class="prev">이전</a>
				<ul>
					<li><a href="#" class="active">1</a></li>
					<li><a href="#">2</a></li>
					<li><a href="#">3</a></li>
					<li><a href="#">4</a></li>
					<li><a href="#">5</a></li>
				</ul>
				<a href="#" class="next">다음</a>
			</div>-->
			<div class="btngroup">
				<ul class="btn_nrm column3">
					<li><a href="#chk" onclick="chkAllByTagName('chk_new_number', true);" class="nrm2">전체선택</a></li>
					<li><a href="#chk" onclick="chkAllByTagName('chk_new_number', false);" class="nrm2">전체해제</a></li>
					<li><a href="#seladd" onclick="memAdd('chk_new_number');closeArea();" class="nrm1">선택추가</a></li>
				</ul>
			</div>