<%@ Language=VBScript %> <% Option Explicit %> <% 'Open connection string using App variable Dim sConn, con, ProjID, sFilter sConn=Application("TMAConnectString") Set con=Server.CreateObject("ADODB.Connection") con.ConnectionString=sConn con.Open Const MaxPerPage=25 ProjID=Session("ProjID") sFilter=Request("Filter") Function QAGrabber(str,MaxChars,QAType) QAGrabber=iif(Len(str)<=MaxChars, str, Left(str, InStr(MaxChars, str & " ", " "))) If Len(str) >= MaxChars then 'add ellipses If QAType="Q" then If Right(str,1) = "?" then QAGrabber=Left(QAGrabber,Len(QAGrabber)-1) & "...?" Else QAGrabber=QAGrabber & "..." End If Else QAGrabber=QAGrabber & "..." End If End If End Function %> TMA Admin Section <% 'Create a recordset object instance and retrieve the information from the table Dim rs, SQL, sTitle, sLink, intPage intPage=Request.QueryString("Page") If intPage="" or intPage=0 then 'If Len(intPage<1) or intPage=0 then intPage=1 Else intPage=Cint(Request.QueryString("Page")) End If 'Open the main recordset Set rs = Server.CreateObject("ADODB.Recordset") rs.CursorType = adOpenStatic rs.CursorLocation = adUseClient rs.LockType = adLockPessimistic SQL="SELECT * FROM Questions " _ & "WHERE ProjectID=" & ProjID & " " If sFilter="unans" then 'select unanswered questions only sTitle="View Unanswered Questions" SQL=SQL & "AND Answer is Null " sLink="View All Questions" Else sTitle="View All Questions" sLink="View Unanswered Questions Only" End If SQL=SQL & "ORDER BY Type, QuestionDate DESC" rs.Open SQL, con 'Count the number of records & determine number of pages Dim intRecCount, intID, intNumPages, sngDiv, intCnt QAClass="#FFFFFF" If rs.EOF then intRecCount=0 intNumPages=1 Else intRecCount=rs.RecordCount sngDiv=intRecCount/MaxPerPage intNumPages=Fix(sngDiv) If (intNumPages-sngDiv) < 0 then intNumpages=intNumPages+1 End If End If %>

<%=sTitle%>

<%=sLink%> | Add New Question | Back to Main Admin Page

<% 'Top page numbers %> Go to page: <% For intCnt=1 to intNumPages If intCnt=intPage then %> <%=intCnt%> <% Else %> <%=intCnt%> <% End If Next %>    (<%=MaxPerPage%> questions per page) <%=intRecCount%> questions currently in database
 
<% If rs.EOF then Response.Write("") Else Dim QAClass QAClass="QAWhite" 'Fix number of Questions to list per page by setting up for/next loop or count. Check to see if EOF within loop. Dim intQuestionCount, intPageNum, intLoopCnt, intFirstQuestion, sQuestion, sAnswer intQuestionCount=0 intPageNum=intPage intLoopCnt=0 'Look for starting Question, based on page number If intPageNum=1 then intFirstQuestion=0 Else intFirstQuestion=(intPageNum-1)*MaxPerPage For intLoopCnt=1 to intFirstQuestion rs.MoveNext Next End If Do While Not (rs.EOF or intQuestionCount=MaxPerPage) sQuestion=QAGrabber(rs("Question"),50,"Q") sAnswer=QAGrabber(rs("Answer"),50,"A") %> <% rs.MoveNext If QAClass="QAWhite" then QAClass="QAGray" Else QAClass="QAWhite" End If %> <% intQuestionCount=intQuestionCount+1 Loop End If %>
Type Date
Posted
Question Date
Answered
Answer
No questions found.
<%=iif(rs("Type")="ToTMA", "To TMA", "To Client")%> <%=rs("QuestionDate")%> &ID=<%=rs("ID")%>&Page=<%=intPageNum%>"><%=sQuestion%> <%=rs("AnswerDate")%> <%=sAnswer%>
       
<% 'Top page numbers %> Go to page: <% For intCnt=1 to intNumPages If intCnt=intPage then %> <%=intCnt%> <% Else %> <%=intCnt%> <% End If Next %>    (<%=MaxPerPage%> Questions per page)
     

Return to top of page

<%=sLink%> | Add New Question | Back to Main Admin Page

<% 'Clean up our ADO objects rs.Close Set rs=Nothing con.Close Set con=Nothing %>