%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%
' *** Restrict Access To Page: Grant or deny access to this page
MM_authorizedUsers=""
MM_authFailedURL="/Bookings/Secure/logOn.asp"
MM_grantAccess=false
If Session("MM_Username") <> "" Then
If (true Or CStr(Session("MM_UserAuthorization"))="") Or _
(InStr(1,MM_authorizedUsers,Session("MM_UserAuthorization"))>=1) Then
MM_grantAccess = true
End If
End If
If Not MM_grantAccess Then
MM_qsChar = "?"
If (InStr(1,MM_authFailedURL,"?") >= 1) Then MM_qsChar = "&"
MM_referrer = Request.ServerVariables("URL")
if (Len(Request.QueryString()) > 0) Then MM_referrer = MM_referrer & "?" & Request.QueryString()
MM_authFailedURL = MM_authFailedURL & MM_qsChar & "accessdenied=" & Server.URLEncode(MM_referrer)
Response.Redirect(MM_authFailedURL)
End If
%>
<%' ====================================================================================
' Get from & to dates passed - set defaults if not passed - check "To" is before "From"
Dim TB_from, TB_to, SQLfrom, SQLto
TB_from = UKDate(Now()-1)
if Request.QueryString("actFrom") <> "" then ' was from value assed
TB_from = Request.QueryString("actFrom") ' use from value
end if
SQLfrom = USDate(TB_from) ' Format "from" date for SQL use
TB_to = UKDate(Now()+61) ' init set to value 31 days after to value
if Request.QueryString("actTo") <> "" then ' was to value passed
TB_to = Request.QueryString("actTo") ' use from value passed
end if
SQLto = USDATE1(TB_to) ' format "to" date for SQL use (needs to be 1 day greater)
' =====================================================================================%>
<%' ====================================================================================
' Get URL + Query String value for this page to use if returning later.
TB_callPage = CStr(Request.ServerVariables("SCRIPT_NAME"))
TB_callPage = TB_callPage & "?" & Server.HTMLEncode(Request.QueryString)
Session("TB_callPage") = TB_callPage ' Save this pages UR + Query String for future recall
' =====================================================================================%>
<%
Dim actList
Dim actList_cmd
Dim actList_numRows
Set actList_cmd = Server.CreateObject ("ADODB.Command")
actList_cmd.ActiveConnection = MM_trevs_STRING
actList_cmd.CommandText = "SELECT IDunit, Uname, UType FROM Units WHERE UType = 'Equip' ORDER BY Uname"
actList_cmd.Prepared = true
Set actList = actList_cmd.Execute
actList_numRows = 0
%>
<%
Dim actDiary__diaryTo
actDiary__diaryTo = "" & Now()+61 & ""
If (SQLto <> "") Then
actDiary__diaryTo = SQLto
End If
%>
<%
Dim actDiary__diaryFrom
actDiary__diaryFrom = "" & Now()-1 & ""
If (SQLfrom <> "") Then
actDiary__diaryFrom = SQLfrom
End If
%>
<%
Dim actDiary__diaryAct
actDiary__diaryAct = "%"
If (Request.QueryString("actType") <> "") Then
actDiary__diaryAct = Request.QueryString("actType")
End If
%>
<%
Dim actDiary
Dim actDiary_cmd
Dim actDiary_numRows
Set actDiary_cmd = Server.CreateObject ("ADODB.Command")
actDiary_cmd.ActiveConnection = MM_trevs_STRING
actDiary_cmd.CommandText = "SELECT * FROM activityReport WHERE UType = 'Equip' AND Bfrom< ? AND Bto > ? AND Uname LIKE ? ORDER BY Bfrom"
actDiary_cmd.Prepared = true
actDiary_cmd.Parameters.Append actDiary_cmd.CreateParameter("param1", 135, 1, -1, actDiary__diaryTo) ' adDBTimeStamp
actDiary_cmd.Parameters.Append actDiary_cmd.CreateParameter("param2", 135, 1, -1, actDiary__diaryFrom) ' adDBTimeStamp
actDiary_cmd.Parameters.Append actDiary_cmd.CreateParameter("param3", 200, 1, 255, actDiary__diaryAct) ' adVarChar
Set actDiary = actDiary_cmd.Execute
actDiary_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index
Repeat1__numRows = -1
Repeat1__index = 0
actDiary_numRows = actDiary_numRows + Repeat1__numRows
%>
<%
While ((Repeat1__numRows <> 0) AND (NOT actDiary.EOF))
%>
<% 'Trevs - Set font colour - Normal or Pale if all leaders already found
LdrCount = 0 ' This will become the number of Actvity Leaders signed up on RATS
If Len(actDiary.Fields.Item("permitH1").Value)>3 then LdrCount = LdrCount+1
If Len(actDiary.Fields.Item("permitH2").Value)>3 then LdrCount = LdrCount+1
If Len(actDiary.Fields.Item("permitH3").Value)>3 then LdrCount = LdrCount+1
%>
<% 'Trev's - Sets numbe rof rhydd leaders to numeric value
If IsNumeric(actDiary.Fields.Item("numRydLdrs").Value) then
LdrsNeeded = CSng(actDiary.Fields.Item("numRydLdrs").Value)
Else
LdrsNeeded = 0
End If%>
<% 'Trev's - Set flag if enough leaders already volunteered
LdrsDone = False
If LdrCount >= LdrsNeeded then LdrsDone = True
'Trev's - Set font strength dependant on if leaders still needed
If LdrsDone then
ActStyle = "tablePale"
Else
ActStyle = "tableRep"
End If
%>
<% 'Trevs - Set up acceptance link QueryString to be passed to asp page
' for sending on in an emails and updating the database
TB_H_start = "accept" 'End of offer link
%>
<% ' Trev's - Set session date and times into sDates / Set Group name into grpName
sDates = dateSht((actDiary.Fields.Item("Bfrom").Value)) & " to " & dateSht((actDiary.Fields.Item("Bto").Value))
grpName = (actDiary.Fields.Item("Cgroup").Value)
grpName = Left(grpName,23)
%>
<%'-------------------------------------------------------------------------------------------------------------%>
<%' Trevs - insert activity leaders name or link to accept activity (only in left most slot)
linkSet = False 'Set flag to say "accept link" not yet inserted%>
<% 'Trevs - Set up the content of leader columns - i.e. name, not used or a link to say I'll do it
' 1st leader column -----------------------------------------------------------------------------
If LdrCount >= LdrsNeeded then 'Already got enough activity leaders
If Len(actDiary.Fields.Item("permitH1").Value)<2 then ' No volunteer for H1 yet
H1 = ""
Else ' H1 already has a volunteer
H1 = (actDiary.Fields.Item("permitH1").Value)
End If
Else 'Not yet enough activity leaders
If Len(actDiary.Fields.Item("permitH1").Value)>1 then ' H1 Already has a volunteer
H1 = (actDiary.Fields.Item("permitH1").Value)
Else ' H1 does not yet have a volunter
If linkSet then ' The link to volunteer has already been inserted
H1 = ""
Else ' The link to volunteer has not yet been inserted
H1 = TB_H_start & "?actNo=" & (actDiary.Fields.Item("IDbooking").Value) & "&IDunit=" & (actDiary.Fields.Item("IDunit").Value) & "&activity=" & (actDiary.Fields.Item("Uname").Value) & "&leader=H1" & TB_H_end
linkSet = True ' Set the flag to say link has been inserted
End if
End If
End If
If Len(H1)<2 then ' H1 field is blank
H1 = " "
End If
' 2nd leader column -----------------------------------------------------------------------------
If LdrCount >= LdrsNeeded then 'Already got enough activity leaders
If Len(actDiary.Fields.Item("permitH2").Value)<2 then ' No volunteer for H2 yet
H2 = ""
Else ' H2 already has a volunteer
H2 = (actDiary.Fields.Item("permitH2").Value)
End If
Else 'Not yet enough activity leaders
If Len(actDiary.Fields.Item("permitH2").Value)>1 then ' H2 Already has a volunteer
H2 = (actDiary.Fields.Item("permitH2").Value)
Else ' H2 does not yet have a volunter
If linkSet then ' The link to volunteer has already been inserted
H2 = ""
Else ' The link to volunteer has not yet been inserted
H2 = TB_H_start & "?actNo=" & (actDiary.Fields.Item("IDbooking").Value) & "&IDunit=" & (actDiary.Fields.Item("IDunit").Value) & "&leader=H2" & TB_H_end
linkSet = True ' Set the flag tosay link has been inserted
End if
End If
End If
If Len(H2)<2 then ' H2 field is blank
H2 = " "
End If
' 3rd leader column -----------------------------------------------------------------------------
If LdrCount >= LdrsNeeded then 'Already got enough activity leaders
If Len(actDiary.Fields.Item("permitH3").Value)<2 then ' No volunteer for H3 yet
H3 = ""
Else ' H3 already has a volunteer
H3 = (actDiary.Fields.Item("permitH3").Value)
End If
Else 'Not yet enough activity leaders
If Len(actDiary.Fields.Item("permitH3").Value)>1 then ' H3 Already has a volunteer
H3 = (actDiary.Fields.Item("permitH3").Value)
Else ' H3 does not yet have a volunter
If linkSet then ' The link to volunteer has already been inserted
H3 = ""
Else ' The link to volunteer has not yet been inserted
H3 = TB_H_start & "?actNo=" & (actDiary.Fields.Item("IDbooking").Value) & "&IDunit=" & (actDiary.Fields.Item("IDunit").Value) & "&leader=H3" & TB_H_end
linkSet = True ' Set the flag tosay link has been inserted
End if
End If
End If
If Len(H3)<2 then ' H3 field is blank
H3 = " "
End If
%>
<%
actList.Close()
Set actList = Nothing
%>
<%
actDiary.Close()
Set actDiary = Nothing
%>
<% 'Returns the date formatted to Medium length ie "27 Jun 57"
function dateMed(dt)
dateMed=Day(dt)
dateMed=dateMed & " " & MonthName(Month(dt),true)
dateMed=dateMed & " " & Right(Year(dt),2)
end function
%>
<% 'Returns date in US format to SAVE in database (No hashes)
'Also swops between UK and US format for displaying
Function USDate(x)
If Not IsDate(x) Then Exit Function
USDate = Month(x) & "/" & Day(x) & "/" & Year(x)
End Function
%>
<% 'Returns date in US format plus ONE DAY for "SQL TO" Selection 06/28/57
Function USDate1(x)
Dim x1
If Not IsDate(x) Then Exit Function
x1=CDate(x)+1 ' Get Date plus ONE DAY
USDate1 = Month(x1) & "/" & Day(x1) & "/" & Year(x1)
End Function
%>
<% 'Returns date in UK format to display (No hashes) 27/06/57
Function UKDate(x)
If Not IsDate(x) Then Exit Function
UKDate = Day(x) & "/" & Month(x) & "/" & Right(Year(x),2)
End Function
%>
<% 'Returns the date & Time ie Tu 27 Jun 11:56"
function dateSht(dt)
dateSht=(WeekdayName(Weekday(dt),true))
dateSht=dateSht & " " & Day(dt)
dateSht=dateSht & " " & MonthNAme(Month(dt),true)
' dateTim=DateTim & " " & Right(Year(dt),2)
if Hour(dt)<10 then ' set hour leading zero if needed
dateSht=dateSht & " 0" & Hour(dt)
else
dateSht=dateSht & " " & Hour(dt)
end if
if Minute(dt)<10 then'set minute leading zero in needed
dateSht=dateSht & ":0" & Minute(dt)
else
dateSht=dateSht & ":" & Minute(dt)
end if
end function
%>
<% 'Returns just the Time ie 09:56"
function onlyTim(dt)
if Hour(dt)<10 then ' set hour leading zero if needed
onlyTim=onlyTim & " 0" & Hour(dt)
else
onlyTim=onlyTim & " " & Hour(dt)
end if
if Minute(dt)<10 then'set minute leading zero in needed
onlyTim=onlyTim & ":0" & Minute(dt)
else
onlyTim=onlyTim & ":" & Minute(dt)
end if
end function
%>