<%@ LANGUAGE="VBScript" %> <% Dim Words(100) If IsEmpty(Request.form("days")) Then days=10 Else On Error Resume Next days=CInt(Request.Form("days")) If Not Err.Number=0 Then days=10 End If End If days_Sql=days-1 If days_Sql<0 Then days_Sql=0 End If If (Trim(Request.Form("query"))="") Then query="" SQL_Condition="" iquery=0 Else ' Parse Query ' ' a) Remove confusing characters ' query=CStr(Request.Form("query")) query=Replace(query,"'","") ' ' b) Separate parentheses from words, do it by adding spaces, just in case ' query=Replace(query,"("," ( ") query=Replace(query,")"," ) ") ' ' c) Get rid of starting and ending blanks ' query=Trim(query) ' ' d) split the string ' Words(iword)="" iword=0 iblank=1 For ichar=1 to Len(query) charact=Mid(query,ichar,1) ' response.write("-" & CStr(ichar) & "-" & charact & "-
") If charact<>" " Then Words(iword)=Words(iword) & charact iblank=0 Else If iblank=0 Then ' new word: blank encountered where there was no blank before iword=iword+1 End if iblank=1 End if Next nwords=iword+1 ' ' Prepare SQL Condition that will go at the end of statement ' iandor=-1 SQL_Condition="(" For iwords=0 to nwords-1 one_word=UCase(CStr(Words(iwords))) Select Case one_word Case "(" If iandor=0 Then SQL_Condition=SQL_Condition & " OR " End If SQL_Condition=SQL_Condition & one_word iandor=2 Case ")" iandor=2 SQL_Condition=SQL_Condition & one_word Case "AND","OR" SQL_Condition=SQL_Condition & " " & one_word & " " iandor=1 Case "NOT" If iandor=0 Then SQL_Condition=SQL_Condition & " AND " End If SQL_Condition=SQL_Condition & " " & one_word & " " iandor=1 Case Else If iandor=0 Then SQL_Condition=SQL_Condition & " OR " End If SQL_Condition=SQL_Condition & " UPPER(lc.TEXT) LIKE " & "'%" & one_word & "%' " iandor=0 End Select Next SQL_Condition=SQL_Condition & ")" ' response.write(SQL_Condition & "
") iquery=1 End if If Trim(Request.Form("qname"))="" Then qname="" SQL_Operator="" iqname=0 Else qname=CStr(Trim(Request.Form("qname"))) SQL_Operator=" (UPPER(lo.operator) LIKE '%" & UCase(qname) & "%') " iqname=1 End If ' response.write(SQL_Operator & "
") If iquery=1 or iqname=1 Then Set Connection = Server.CreateObject("ADODB.Connection") Connection.Mode = adModeRead Connection.Open phdb_rd_repl SQLStmtx = "select to_char(sysdate,'DD Mon YYYY') ddate,to_char(sysdate,'HH24:MI:SS') ttime,global_name from global_name " ' response.write(SQLStmtx & "
" ) Set RSx = Connection.Execute(SQLStmtx) If Not RSx.EOF Then select case CStr(RSx("global_name")) case "PHDB.WORLD" dbname="Main Phobos Database" case "ORACLE.WORLD" dbname="Phobos Server (old) Database" case "KRPHOBOS.WORLD" dbname="Krakow Database" case "ROCHESTER.WORLD" dbname="Rochester Database" end select Else dbname="Undefined Database" End If ddate=CStr(RSX("ddate")) ttime=CStr(RSX("ttime")) Set RSX=nothing SQLStmt = " select to_char(max(le.log_date),'MM/DD/YYYY') ldate,to_char(max(le.log_date),'MM/DD/YY HH24:MI') ddate, max(le.logid) logidd, " SQLStmt = SQLStmt & " max(le.log_date) log_date_s, max(le.action) action,max(lc.text) user_comment,min(lo.operator) operator1,max(operator) operator2 " SQLStmt = SQLStmt & " FROM phoffline.log_entries le, phoffline.log_comments lc,phoffline.log_operators lo " SQLStmt = SQLStmt & " where lc.logid(+)=le.logid and lo.logid(+)=le.logid " SQLStmt = SQLStmt & " and (le.action like '%SHIFT%' or le.action='SI_CONFIG_CHANGE' or le.action='LOGBOOK_PICTURE' or le.action='COMMENT') " If iquery=1 Then SQLStmt = SQLStmt & " and " & SQL_Condition End If If iqname=1 Then SQLStmt = SQLStmt & " and " & SQL_Operator End If SQLStmt = SQLStmt & " and le.log_date>to_date(to_char(sysdate,'DD-MON-YYYY'),'DD-MON-YYYY')-" & days_Sql SQLStmt = SQLStmt & " group by le.logid " SQLStmt = SQLStmt & " order by log_date_s desc " ' ' response.write(SQLStmt & "
" ) ' On Error Resume Next Set RS = Connection.Execute(SQLStmt) If Not Err.Number=0 Then ' response.write(Hex(Err.Number) & "
" & vbCrLf) ' response.write(Err.Description & "
" & vbCrLf) message="Error in accessing the database, most likely wrong query syntax, try again" iquery=0 End If End If ' end iquery %> Search Shift Logbook

Search Online Logbook

specify either search string(s) or author's name or both

Query String Help
Operator Name
Days to search

<% If iquery=1 or iqname=1 Then %>

<%=Title%>

Status on  <%=ddate%> at <%=ttime%> in <%=dbname%>

<% Do While Not RS.EoF ddate=(date-datevalue(CStr(RS("ldate")))) If ddate=0 Then rcolor="#BEBE7C" Elseif ddate=1 Then rcolor="#AEBEEE" Else rcolor="#000000" End if If Not IsNull(RS("operator1")) Then operator=CStr(RS("operator1")) If Not RS("operator2")=RS("operator1") Then operator=operator & " and " & RS("operator2") End If Else operator="Unknown" End If If Not IsNull(RS("user_comment")) Then comments=CStr(RS("user_comment")) commentsbr= Replace(comments,Chr(13) & Chr(10),"
",1,-1,1) Else comments="" commentsbr="" End If %> <% RS.MoveNext Loop Set RS=nothing %>
<%= response.write(" (" & CStr(RS("ddate")) & " " & operator & ") ") %> <% If RS("action")="LOGBOOK_PICTURE" Then response.write(" ") commentsbr=Replace(commentsbr,"Picture:"," Picture: ",1,-1,1) Elseif RS("action")="UPDATE_DETSYSTEM" Then response.write("Ch. Det. Status: ") Elseif RS("action")="COMMENT" Then response.write("Run Comment: ") End If response.write(commentsbr) %>
<% Connection.Close Set Connection=nothing Else ' query was not defined If Not Err.Number=0 Then Response.write("" & message & "") Else Response.write("Enter Your Query") End if End If ' end iquery here %>