<!--#include virtual="/common/lib/dbcon.asp"-->
<!--#include virtual="/common/lib/func.asp"-->
<%
	Dim list_rec, callback, message, resOrNot, Rdate, time1, time2, a_num, subject, now_date
	list_rec	= inputValue( Request.Form("list_rec") )
	callback	= inputValue( Request.Form("callback") )
	message		= inputValue( Replace(Request.Form("message"), "'" , "`") )
	resOrNot	= inputValue( Request.Form("resOrNot") )
	Rdate		= inputValue( Request.Form("rdate") )
	time1		= inputValue( Request.Form("time1") )
	time2		= inputValue( Request.Form("time2") )
	a_num		= inputValue( Request.Form("a_num") )

	now_date = Replace( Date(), "-", "" ) & Right("0"&hour(now), 2) & Right("0"&minute(now), 2) & Right("0"&second(now), 2)
	If resOrNot = "Y" Then

		If Not(SMSdateChk(Rdate, time1,time2)) Then
			Back_back2 "지난 날짜/시간의 전송은 하실 수 없습니다!", request.servervariables("http_referer")
		End If
		Rdate = Replace(Rdate, "-", "") & time1 & time2 & "00"

	Else
		Rdate = now_date
	End If
	
	list_rec = Replace(list_rec, " ", "")
	list_rec_arr = Split(list_rec, ",")
	
	For i = 0 To UBound(list_rec_arr)
		If list_rec_arr(i) <> "0" And list_rec_arr(i) <> "" Then
			memInfo = Split(list_rec_arr(i),";")
			subject = StringToHTML( message, 30, false )
			Select Case memInfo(0)
				Case "M" '개인추가, 구성원
					mmsSend phoneValue(memInfo(2)), callback, message, Rdate, a_num

				Case "A" '주소록 전체
					sql = "select adr_name+'^'+adr_mobile1+adr_mobile2+adr_mobile3 as dest_info from bd_address_page where adr_m_id = '"&session("ss_m_id")&"' "
					Call mmsSend2(callback, message, RDate, a_num, sql)

				Case "B" '주소록그룹
					sql = "select adr_name+'^'+adr_mobile1+adr_mobile2+adr_mobile3 as dest_info from bd_address_page where bdm_idx = '" & memInfo(1) & "' AND adr_m_id = '" &session("ss_m_id")&"' "
					Call mmsSend2(callback, message, RDate, a_num, sql)

				Case "C" '부서1
					sql = "select m_name+'^'+m_mobile1+m_mobile2+m_mobile3 as dest_info from member where bdm_idx in (select bdm_idx from bd_menu_page where bdm_ref = '" & memInfo(1) & "' and bdm_chk = 'Y') and m_mobile1 <> '' and m_mobile2 <> '' and m_mobile3 <> '' AND m_id = '" & session("ss_m_id") & "' "
					Call mmsSend2(callback, message, RDate, a_num, sql)

				Case "D" '부서2
					sql = "select m_name+'^'+m_mobile1+m_mobile2+m_mobile3 as dest_info from member where bdm_idx = '" & memInfo(1) & "' and m_mobile1 <> '' and m_mobile2 <> '' and m_mobile3 <> '' AND m_id = '" & session("ss_m_id") & "' "
					'Response.write sql
					'Response.end
					Call mmsSend2(callback, message, RDate, a_num, sql)

				Case "E"	'부서전체
					sql = "select m_name+'^'+m_mobile1+m_mobile2+m_mobile3 as dest_info from member where bdm_idx in ( select bdm_idx from bd_menu_page where bdm_chk = 'Y' and bdm_depth = 2 and bdm_ref in (select bdm_idx from bd_menu_page where bdm_chk = 'Y' and bdm_depth = 1) ) and m_mobile1 <> '' and m_mobile2 <> '' and m_mobile3 <> '' AND m_id = '" & session("ss_m_id") & "' "
					Call mmsSend2(callback, message, RDate, a_num, sql)
			End select
		End If
		
	Next
'Response.end
	Back_back2 "메시지 보내기 성공\n\n전송에 관한 성공/실패 여부는 보낸문자함에서 확인 하세요.",request.servervariables("http_referer")


'=======================전화번호 필터==========================
Function phoneValue(value)
	'response.write value
	phone_arr_temp = value
	'---------------불필요한 문자열 제거------------------
	phone_arr_temp = Replace(phone_arr_temp,")","")
	phone_arr_temp = Replace(phone_arr_temp,"(","")
	phone_arr_temp = Replace(phone_arr_temp,"-","")
	phone_arr_temp = Replace(phone_arr_temp," ","")

	phone_arr_temp = Replace(phone_arr_temp,"ㅡ","")
	phone_arr_temp = Replace(phone_arr_temp,"*","")
	'---------------불필요한 문자열 제거------------------
	
	'phone_arr_temp = Split(mem_list(4, i), "-")
	
	If Left(phone_arr_temp, 2) = "00" Then	'지역번호에 0이 2개 들어갔을 경우
		phone_arr_temp = Mid(phone_arr_temp, 2)
	End if	
	'response.write "["& mem_list(4, i) &"], "
	
	'---------------전화번호를 정규화------------------			
	Select Case Len(phone_arr_temp)
		Case 7
			phone_arr = Array("053",Left(phone_arr_temp,3),right(phone_arr_temp,4))
		Case 8
			phone_arr = Array("053",Left(phone_arr_temp,4),right(phone_arr_temp,4))
		Case 10
			phone_arr = Array(Left(phone_arr_temp,3),mid(phone_arr_temp,4,3),right(phone_arr_temp,4))
		Case 11
			phone_arr = Array(Left(phone_arr_temp,3),mid(phone_arr_temp,4,4),right(phone_arr_temp,4))
		Case 12
			phone_arr = Array(Left(phone_arr_temp,4),mid(phone_arr_temp,5,4),right(phone_arr_temp,4))
		Case Else
			phone_arr = Array("","","")
	End select			
	'---------------전화번호를 정규화끝------------------
	'---------------마지막필터 숫자냐---------------
	If IsNumeric(phone_arr(0)) And IsNumeric(phone_arr(1)) And IsNumeric(phone_arr(2)) Then
		M_phone = phone_arr(0) & phone_arr(1) & phone_arr(2)
	Else
		M_phone = ""
	End If
	'---------------마지막필터 숫자냐---------------
	phoneValue = M_phone
End Function

'=======================전화번호 필터 끝==========================
%>
