<%
Dim cn, rs
Set cn = Server.CreateObject("ADODB.Connection")
cn.Open "DSN=database;Uid=*****;Pwd=*****;"
SQLStmt = "SELECT * FROM Youths WHERE Status='active' ORDER BY YLName, YFName"
set rs = cn.Execute(SQLStmt)
%>
<HTML>
<head>
<title>Therapeutic Consequence Entry</title>
</head>
<body>
<span style="font-size: 16pt">Therapeutic Consequence Entry System<br />
</span>
<form method="post" name="Form1">
<table>
<tr>
<td style="width: 225px;">
Select Youth --></td>
<td style="width: 310px;">
<select name="YouthID" onchange="Form1.action='default.asp';Form1.submit();">
<option value="0">Select Youth....</option>
<%
Do Until rs.EOF
Response.Write "<option value='" & rs("YouthID") & "'"
If Trim(Request.Form("YouthID")) = Trim(rs("YouthID")) Then
Response.Write " selected"
End If
Response.Write ">" & rs("YLName") & ", " & rs("YFName") & "</option>"
rs.MoveNext
Loop
%>
</select>
</TD>
<td style="width: 508px; height: 31px">
Behavior change wanted (will show up on sanction)</td>
</TR><tr>
<td style="width: 225px">
Select Category -->
</td>
<td style="width: 310px">
<select name="category" onchange="Form1.action='default.asp';Form1.submit();">
<option value="0">Select Category...</option>
<%
cn.Close
cn.Open "DSN=Logging; Uid=*****;Pwd=*****;"
SQLStmt = "SELECT DISTINCT Category FROM Cons_Lookup ORDER BY Category; "
Set rs = cn.Execute(SQLStmt)
Do Until rs.EOF
Response.Write "<option value='" & rs("Category") & "'"
If Request.Form("category") = rs("Category") Then
Response.Write " selected"
End If
Response.Write ">" & rs("Category") & "</option>"
rs.MoveNext
Loop
cn.Close
%>
</select>
</td>
<td style="width: 508px" rowspan="3" valign="top">
<textarea name="tbehave" id="tbehave" style="width: 463px; height: 157px">
</textarea></td>
</tr>
<tr>
<td style="width: 225px">
Select Violation --></td><td style="width: 310px">
<select name="Violation" onchange="Form1.action='default.asp';Form1.submit();">
<%
If Request.Form("Category") <> "" AND Request.Form("Category") <> "0" Then
Response.Write "<option value='0'>Select Violation...</option>"
' populate the next portion
cn.Open "DSN=LoggingSQL; Uid=sa;Pwd=;"
SQLStmt = "SELECT * FROM Cons_Lookup WHERE Category='" & Request.Form("Category") & "' ORDER BY Category; "
Set rs = cn.Execute(SQLStmt)
Do Until rs.EOF
Response.Write "<option value='" & rs("Violation") & "'"
If Request.Form("Violation") = rs("Violation") Then
Response.Write " selected"
iViolationLevel = rs("Ranking")
setFlag = 1
Else
setFlag = 0
End If
Response.Write ">" & rs("Violation") & "</option>"
If setFlag = 1 Then
strText = Trim(rs("BehaviorChange"))
strText = replace(strText, chr(39), "`") ' Eliminate Single apostrophe
strText = replace(strText, chr(34), "`") ' Eliminate Double Quote Sign
strText = replace(strText, chr(145), "`") ' Eliminate OPEN Single Quote Sign
strText = replace(strText, chr(146), "`") ' Eliminate CLOSE Single Quote Sign
strText = replace(strText, chr(147), "`") ' Eliminate OPEN Double Quote Sign
strText = replace(strText, chr(148), "`") ' Eliminate CLOSE Double Quote Sign
Response.Write "<script language='Javascript'>Form1.tbehave.value='" & strText & "';</script>"
setFlag = 0
End If
rs.MoveNext
Loop
rs.close
Else
setFlag = 0
Response.Write "<option value='0'>Select Category First...</option>"
End If
%>
</select></td>
</tr>
<tr>
<td style="width: 225px; height: 115px;" valign="top">
Select Consequence -->
</td>
<td style="width: 310px; height: 115px;" valign="top">
<select name="Consequence">
<%
' First, put up the RECOMMENDED consequences for the action
If Request.Form("Violation") <> "" AND Request.Form("Violation") <> "0" Then
Response.Write "<option value='0'>Select Consequence...</option>"
SQLStmt = "SELECT * FROM Cons_Lookup WHERE Category='" & Request.Form("Category") & "' AND Violation='" & Request.Form("Violation") & "'; "
Set rs = cn.Execute(SQLStmt)
If rs.BOF AND rs.EOF Then
Response.Write "No Consequences found for category " & Category & ". Please call MIS."
Response.End
Else
' Put these consequences first... there may be up to 4... but there will always be at least one...
Response.Write "<optgroup label='Recommended Consequences'>"
Response.Write "<option>" & rs("Recommend1") & "</option>"
If rs("Recommend2") <> "" Then
Response.Write "<option>" & rs("Recommend2") & "</option>"
End If
If rs("Recommend3") <> "" Then
Response.Write "<option>" & rs("Recommend3") & "</option>"
End If
If rs("Recommend4") <> "" Then
Response.Write "<option>" & rs("Recommend4") & "</option>"
End If
End If
' We put up the recommended ones.... now put up the others in the same violation level....
Response.Write "</optgroup><optgroup label='Other Consequences'>"
If Request.Form("Repeated") = "on" Then
SQLStmt = "SELECT DISTINCT Recommend1 FROM Cons_Lookup WHERE (Ranking <= '" & iViolationLevel + 1 & "' AND Category='" & Request.Form("Category") & "') ORDER BY Recommend1; "
Else
SQLStmt = "SELECT DISTINCT Recommend1 FROM Cons_Lookup WHERE (Ranking='" & iViolationLevel & "' AND Category='" & Request.Form("Category") & "') ORDER BY Recommend1; "
End If
Set rs = cn.Execute(SQLStmt)
Do while not rs.EOF
Response.Write "<option>" & rs("Recommend1") & "</option>"
'If rs("Recommend2") <> "" Then
' Response.Write "<option>" & rs("Recommend2") & "</option>"
'End If
'If rs("Recommend3") <> "" Then
' Response.Write "<option>" & rs("Recommend3") & "</option>"
'End If
'If rs("Recommend4") <> "" Then
' Response.Write "<option>" & rs("Recommend4") & "</option>"
'End If
rs.MoveNext
Loop
rs.close
Response.Write "<option>Consequence from Treatment Plan</option></optgroup>"
Else
Response.Write "<option value='0'>Select Violation first...</option>"
End If
%>
</select>
<br />Therapeutic Consequence Entry:<br />
<textarea name="other" cols=30 rows=4></textarea>
</td>
</tr>
<tr>
<td style="width: 225px; height: 115px" valign="top">
Staff Name: <%=Session("UserID") %>
</td>
<td style="width: 310px; height: 115px" valign="top"><button type="button" OnClick="Form1.action='postcons.asp';Form1.submit();" >Click once to submit!</button>
</td>
<td rowspan="1" style="width: 508px" valign="top">
<%
Response.Write "<input type='checkbox' name='repeated' "
If Request.Form("repeated") = "on" Then
Response.Write "checked "
End If
Response.Write "onclick=""Form1.action='default.asp';Form1.submit();"" /><-- Check here if repeated behavior (this will increase the severity of the consequences, but also alert a supervisor)"
%>
</td>
</tr>
</table>
</form>
</body>
</HTML>