<!--#include virtual = "/common/lib/dbcon.asp" -->
<!--#include virtual = "/common/lib/func.asp" -->
<% 
dim cprCon
set cprCon = Server.CreateObject("ADODB.Connection")
cprCon.Open "Driver={MySQL ODBC 8.0 Unicode Driver}; Server=175.126.77.226; Database=home_cprknuh_201512; Uid=cpr;Pwd=cprknuh;"
if cprCon.errors.count = 0 then
  response.write "Connected Successfully!"
end if


sql = "SELECT s_idx, s_yy, s_mm, s_phone FROM cronjobs_sms WHERE (s_result='' or s_result='-2') order by s_idx"
Set sms_rs = cprCon.Execute(sql)
If sms_rs.bof Or sms_rs.eof Then
	sms_data1 = Null
Else
	sms_data1 = sms_rs.getrows
End If
Set sms_rs = Nothing
'-------------------개인주소록 리스트 끝-----------------------

'update cronjobs_sms set s_result=''

'M_ID = "nninc"
M_ID = "cprknuh"

'이틀전꺼 결과값 없는거는 실패처리
sql = "UPDATE cronjobs_sms SET s_result='3' WHERE s_senddate  < date_add(curdate(), interval -2 day) and s_result='' "
cprCon.execute sql

If Not(IsNull(sms_data1)) Then
		For i = 0 To UBound(sms_data1, 2)

		s_idx		= Replace(sms_data1(0,i)," ","")
		s_yy			= Replace(sms_data1(1,i)," ","")
		s_mm		= Replace(sms_data1(2,i)," ","")
		s_phone	= Replace(sms_data1(3,i)," ","")

		y_month = Mid(s_yy, 3, 4)&Right( "0" & s_mm, 2)
		If y_month = "" Then ' 없으면 초기화
			y_month = Mid(getDateFm(Now(), 6), 3, 4)
		End If

		'월별 테이블에서 조회..
		sql = " SELECT JOB_ID FROM SDK_MMS_REPORT_"&y_month&" WHERE USER_ID='"& M_ID &"' AND RESERVED1<>'situation' AND RESERVED5='"&s_idx&"' AND dest_info like'%"& s_phone &"%' "
		Set Rs = Dbcon.Execute (sql)
		If rs.eof Then
		Else
			sql = " SELECT RESULT FROM SDK_MMS_REPORT_DETAIL_"&y_month&" WHERE USER_ID='"& M_ID &"' AND JOB_ID='"&Rs("JOB_ID")&"' "
			Set Rs_R = Dbcon.Execute (sql)
			If Rs_R.eof Then
			Else
			result = Rs_R("RESULT")

			'결과값 업데이트 
			sql = " UPDATE cronjobs_sms SET s_result='"&result&"' WHERE s_idx='"&s_idx&"' "
			cprCon.execute sql
			End If 
			Rs_R.close : Set Rs_R = Nothing
		End If
		rs.close : Set rs = Nothing

		Next
End If

cprCon.close
set cprCon = Nothing
%>