<%

	'###########################################################################################
	'설문 쿼터 체크
	'###########################################################################################
	Function checkQuota(Quota_Variable)

		Dim Q_SQL,QQ_SQL,QuotaItem
		Dim QQRS,QRS
		Dim icnt

		If Quota_Variable="" Then
			Response.Write "쿼터 변수가 설정되어 있지 않습니다. 쿼터변수를 설정해 주세요"
			Response.End
		End If

		QQ_SQL = "SELECT * FROM "& Quota_TBNAME & " WHERE "
		Q_SQL = "SELECT COUNT(IDX) FROM " & TB_NAME & " WHERE [ResType]<>'TEST' AND Status in (9,10)  "

		If InStr(Quota_Variable,",")=0 Then
            Redim QuotaItem(1)
			QuotaItem(0) = Quota_Variable
		Else
			QuotaItem = Split(Quota_Variable,",")
		End If

		For icnt=0 to UBound(QuotaItem)
             If QuotaItem(icnt)<>"" Then
        			Q_SQL =  Q_SQL &" AND " & QuotaItem(icnt) & "='" & getValue(QuotaItem(icnt)) & "'"
	        		If icnt=0 Then
		        		QQ_SQL = QQ_SQL & QuotaItem(icnt) & "='" & getValue(QuotaItem(icnt)) & "'"
			        ElseIf icnt>0 Then
				        QQ_SQL = QQ_SQL & " AND " & QuotaItem(icnt) & "='" & getValue(QuotaItem(icnt)) & "'"
        			End If
             End If
		Next

		DBConnect()

		Set QRs=Server.CreateObject("ADODB.RecordSet")
		Set QQRs=Server.CreateObject("ADODB.RecordSet")
		
'		Response.WRite Q_SQL & "<br>"
'		Response.WRite QQ_SQL & "<br>"

		QRS.Open Q_SQL,DBConn,3,1,1
		QQRS.Open QQ_SQL,DBConn,3,1,1

		If QQRS.Eof or QQRS.Bof Then
			checkQuota = false
		ElseIf QRS.Eof or QRS.Bof Then
			checkQuota = false
		Else
			If cInt(QQRS("Limit"))>cInt(QRS(0)) Then
				checkQuota=true
			Else
				checkQuota=false
			End if

		End If

		QQRs.Close		

		DBClose()

	End Function
%>
