%@ Language=VBScript %> <%dim colorScheme : colorScheme = "blue" %> <%dim pageTitle : pageTitle = "title_calendar.gif" %> <% Dim iYear Dim iMonth Dim iDay Dim dMinDate : dMinDate = "1/1/2003" Dim dMaxDate : dMaxDate = "12/1/" & CStr(Year(date()) + 2) 'String representations of the year, month, and day (YYYY, MM, DD) for comparisons with the DateID. Dim sYear Dim sMonth Dim sDay Dim sYearMonth Dim sYearMonthDay Dim sDate ' Used for the while loops counters Dim dDate ' Date we're displaying calendar for Dim dDateTemp ' Temp Variable for Date addition/subtraction functions Dim dDateTempMonth ' Temp Variable for Date addition/subtraction functions Dim iDIM ' Days In Month Dim iDOW ' Day Of Week that month starts on Dim iCurrent ' Variable we use to hold current day of month as we write table Dim iPosition ' Variable we use to hold current position in table dim oConn dim oCmd dim oRs dim isAdmin dim sEvents dim sAllDayEvents isAdmin = false ' BUG... implement this. dim iCatId: iCatId = -1 If IsNumeric(Request.Item("category_id")) And Request.Item("category_id") <> "" Then iCatId = CInt(Request.Item("category_id")) Response.Cookies("category_id") = Request.Item("category_id") ElseIf IsNumeric(Request.Cookies("category_id")) And Request.Cookies("category_id") <> "" Then iCatId = CInt(Request.Cookies("category_id")) End If ' Get selected date. There are two ways to do this. ' First check if we were passed a full date in RQS("date"). ' If so use it, if not look for separate variables, putting them together into a date. ' Lastly check if the date is valid...if not use today If IsDate(Request.QueryString("date")) Then dDate = CDate(Request.QueryString("date")) Else If IsDate(Request.QueryString("month") & "-" & Request.QueryString("day") & "-" & Request.QueryString("year")) Then dDate = CDate(Request.QueryString("month") & "-" & Request.QueryString("day") & "-" & Request.QueryString("year")) Else dDate = Date() ' The annoyingly bad solution for those of you running IIS3 If Len(Request.QueryString("month")) <> 0 Or Len(Request.QueryString("day")) <> 0 Or Len(Request.QueryString("year")) <> 0 Or Len(Request.QueryString("date")) <> 0 Then Response.Write "
The date you picked was not a valid date. The calendar was set to today's date.
" End If ' The elegant solution for those of you running IIS4 'If Request.QueryString.Count <> 0 Then Response.Write "The date you picked was not a valid date. The calendar was set to today's date.
|
||||
|
<%dDateTemp = dDate
dDateTempMonth = SubtractOneMonth(dDateTemp)
if datediff("d", dMinDate, dDateTempMonth) >= 0 then
Call renderMiniCalendar(dDateTempMonth, 0, isAdmin, false)
else%>
|
<%dDateTemp = dDate
dDateTempMonth = AddOneMonth(dDateTemp)
if datediff("d", dMaxDate, dDateTempMonth) <= 0 then
Call renderMiniCalendar(dDateTempMonth, 0, isAdmin, false)
else%>
|
|||
| Sun |
Mon |
Tue |
Wed |
Thu |
Fri |
Sat |
|---|---|---|---|---|---|---|
| " & day(dateadd("D", 0 - (iDOW - iPosition), iMonth & "/1/" & iYear)) & " | " & vbCrLf iPosition = iPosition + 1 Loop End If set oCmd = Server.CreateObject("ADODB.Command") with oCmd set .ActiveConnection = oConn .CommandText = "p_SelectCalendarEvents" .CommandType = adCmdStoredProc ' Since the dateID is an int, we compare by numbers, which are created by concatening strings. ' The database won't care that the 20020231 is invalid because February has 28 days... it's still an int. ' As long as months don't have 32 days, we'll be fine. :) sMonth = Month(dDate) if sMonth < 10 then sMonth = "0" & sMonth end if sYearMonth = cDbl(Year(dDate) & sMonth) .Parameters.Append .CreateParameter("@Begin", adDouble, adParamInput, 4, sYearMonth & "01") .Parameters.Append .CreateParameter("@End", adDouble, adParamInput, 4, sYearMonth & "31") If iCatId > -1 Then oCmd.Parameters.Append .CreateParameter("@Category", adDouble, adParamInput, 4, iCatId) End If oCmd.Execute set oRs = Server.CreateObject("ADODB.Recordset") with oRs .Open oCmd,,adOpenForwardOnly,adLockReadOnly '.MoveFirst ' Write days of month in proper day slots iCurrent = 1 iPosition = iDOW Do While iCurrent <= iDIM ' Get the current day in two-digit format --dave 01/10/03 if iCurrent < 10 then sDay = "0" & iCurrent else sDay = iCurrent end if sYearMonthDay = sYearMonth & sDay ' If we're at the beginning of a row then write TR If iPosition = 1 Then Response.Write vbTab & "||||||
| " Response.Write vbCrLf & vbTab & vbTab & vbTab else Response.Write vbTab & vbTab & " | "
Response.Write vbCrLf & vbTab & vbTab & vbTab
end if
if isAdmin then
Response.Write " " end if else 'icon and link (Is this supposed to go to a page with events that have similiar icons??) if len(.Fields("IconFileName").Value) > 0 then sEvents = sEvents & " " & vbCrLf 'link for item sEvents = sEvents & vbTab & vbTab & vbTab & vbTab & vbTab sEvents = sEvents & "" sEvents = sEvents & "" & .Fields("ShortDescription").Value & " " sEvents = sEvents & "" & vbCrLf sEvents = sEvents & vbTab & vbTab & vbTab & vbTab & vbTab end if .MoveNext If Not .EOF then sDate = .Fields("DateID").Value End If Loop if len(sAllDayEvents) > 0 or len(sEvents) > 0 then Response.Write "" & iCurrent & "" & vbcrlf else Response.Write "" & iCurrent & "" & vbcrlf end if if len(sDateIcon) > 0 then Response.Write "
<% if len(sDateTitle) > 0 then %>
<%=sDateTitle%> <% end if %> <% if len(sAllDayEvents) > 0 then %><%=sAllDayEvents%> <% end if %><%=sEvents%> |
<%
' Else
' Response.Write vbTab & vbTab & ""
'
' if isAdmin then
' Response.Write " " ' .MoveNext ' If Not .EOF then ' sDate = .Fields("DateID").Value ' End If ' Loop ' ' 'Response.Write renderDay(Year(dDate),Month(dDate),iCurrent) ' Response.Write " | " & vbCrLf
' End If
' If we're at the endof a row then write /TR
If iPosition = 7 Then
Response.Write vbTab & "" & i & " | " & vbCrLf ' Response.Write vbTab & vbTab & "" & vbCrLf iPosition = iPosition + 1 i = i + 1 Loop Response.Write vbTab & "" & vbCrLf End If %> |