% '************************************************************************************** '* Application: ActionCalendar '* Version: 1.3 '* Author: Andrew L. Warren '* Email: andy@warrenstudios.com '* Publish Date: 03/01/2001 '* Updated: 01/26/2002 '* Copyright: (c) 2001 - 2002 Warren Studios, ALW. All Rights Reserved '* '* Warranties and Terms of Use Agreement: '* No warranties, implied or otherwise, are made regarding the usage of ActionCalendar '* and it's associated code. The users assumes all risk and the Author of '* ActionCalendar is in no part liable for any incurred damages. Execution of this '* code in part or whole constitutes acceptance of the Terms and Agreement for use. '************************************************************************************** '************************************************************************************** '* Function Name: BuildCalendar() * '* Input: Any valid date expression, valid string, empty string. * '* Output: HTML string of the calendar table. Calls GetRequest(), GetEvent(). * '* User Edits: Change the # CONFIGURATION OPTIONS # below if you want to customize * '* the file name and table options. * '************************************************************************************** Function BuildCalendar(srcDate,size) '*** Declare the function variables *** Dim objFirstDOM ' first day of month Dim objLastDOM ' last day of month Dim intDayCount ' increment value for day of week Dim intDateCount ' increment value for date of month Dim objDateDisplay ' calendar display date Dim strTable ' HTML string Dim strEventText ' HTML string for event Dim intHeight ' height for table cells Dim intWidth ' width for table cells Dim intTblBorder ' table border Dim intTblCpad ' cellpadding Dim intTblCspc ' cellspacing Dim strTip ' tool tip message (IE only) Dim i ' Loop counter Dim intPrevMth ' previous month Dim intNextMth ' next month Dim intPrevYear ' previous year Dim intNextYear ' next year Dim objBOW ' beginning of week Dim objEOW ' end of week Dim objPrevWeek ' previous week Dim objNextWeek ' next week If GetRequest("view") = "weekly" Then size = "large" End If '################################################################## '################ CONFIGURATION OPTIONS FOR YOU ################### intTblBorder = 0 ' table border intTblCpad = 2 ' cellpadding intTblCspc = 1 ' cellspacing strTip = "Click for Event Details" ' set to an empty string ("") to disable tool tip '*** Check for Administration View *** If GetRequest("action") = "admin" Then size = "large" ' the admin page MUST be set to the "large" size strTip = "Click to Add a New Event" ' set to an empty string ("") to disable tool tip End If '*** Set the size of the Calendar table *** Select Case size Case "small" intHeight = 10 intWidth = 10 Case "med" intHeight = 30 intWidth = 30 Case "large" intHeight = 80 intWidth = 80 Case "view" intHeight = 200 intWidth = 200 Case Else intHeight = 30 intWidth = 30 size = "med" End Select '############### END CONFIGURATION OPTIONS FOR YOU ################ '###### YOU SHOULD NOT HAVE TO EDIT ANYTHING BELOW THIS LINE ###### '################################################################## '*** Set the First and Last Day's of the Month *** '*** Use line below for English (mm/dd/yyyy) date format objFirstDOM = CDate(Month(srcDate) & "/1/" & Year(srcDate)) '*** Use line below for European (dd/mm/yyyy) date format 'objFirstDOM = CDate("1/" & Month(srcDate) & "/" & Year(srcDate)) objLastDOM = DateAdd("d", -1, DateAdd("m", 1, objFirstDOM)) intPrevMth = Month(srcDate)-1 intPrevYear = Year(srcDate) If intPrevMth <= 0 Then intPrevMth = 12 intPrevYear = Year(DateAdd("yyyy", -1, srcDate)) End If intNextMth = Month(srcDate)+1 intNextYear = Year(srcDate) If intNextMth > 12 Then intNextMth = 1 intNextYear = Year(DateAdd("yyyy", 1, srcDate)) End If '*** Set the Day, Date counters and Calendar Date *** intDayCount = intStartDay intDateCount = intStartDay objDateDisplay = objFirstDOM If GetRequest("view") = "weekly" Then objBOW = GetRequest("date") Do Until WeekDay(objBOW) = intStartDay objBOW = DateAdd("d",-1,objBOW) Loop objEOW = DateAdd("d",6,objBOW) objPrevWeek = DateAdd("d",-1,objBOW) objNextWeek = DateAdd("d",1,objEOW) If Month(objBOW) <> Month(objEOW) Then If Month(GetRequest("date")) <> Month(objBOW) Then objPrevWeek = objBOW ElseIf Month(GetRequest("date")) <> Month(objEOW) Then objNextWeek = objEOW End If End If objDateDisplay = objBOW objLastDOM = objEOW End If '*** Build the Calendar Event View *** If size = "view" Then strTable = "
| Events for " & UCase(strMonth(Month(srcDate)-1)) & " " & Day(srcDate) & ", " & Year(srcDate) & " | " & VbCrLf &_ "||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Month View | " & VbCrLf &_ "Week View | " & VbCrLf &_ "Print View | " & VbCrLf &_ "
|---|
| " If GetRequest("view") = "weekly" Then strTable = strTable & "" &_ "<" &_ " | " & VbCrLf &_ "" If Month(objPrevWeek) <> Month(GetRequest("date")) Then strTable = strTable & "Week of " & Month(GetRequest("date")) & "/1/" & Right(Year(GetRequest("date")),2) Else strTable = strTable & "Week of " & objBOW End If strTable = strTable & " | " & VbCrLf &_ "" &_ "" &_ ">" Else strTable = strTable & "" If size = "small" Then strTable = strTable & "<" Else strTable = strTable & Left(strMonth(intPrevMth-1),3) End If strTable = strTable & " | " & VbCrLf &_ "" & UCase(strMonth(Month(srcDate)-1)) & " - " & Year(srcDate) & " | " & VbCrLf &_ "" &_ "" If size = "small" Then strTable = strTable & ">" Else strTable = strTable & Left(strMonth(intNextMth-1),3) End If End If strTable = strTable & " | " & VbCrLf &_ "||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| " If size = "small" Then strTable = strTable & UCase(Left(WeekDayName(intDayCount,1),1)) Else strTable = strTable & UCase(WeekDayName(intDayCount,1)) End If strTable = strTable & " | " & VbCrLf intDayCount = intDayCount + 1 Next strTable = strTable & "||||||||||||
| " & VbCrLf objDateDisplay = DateAdd("d", 1, objDateDisplay) ElseIf (intDateCount < WeekDay(objDateDisplay)) Or (DateDiff("d", objDateDisplay, objLastDOM) < 0) Then strTable = strTable & " | " & VbCrLf '*** Else write the date to the calendar table *** Else strEventText = GetEvent(objDateDisplay) strTable = strTable & " | "" Then
strTable = strTable & " class=event"
Else
strTable = strTable & " class=default"
End If
strTable = strTable & " height=" & intHeight & " width=" & intWidth & ">"
If size = "large" Then
If GetRequest("action") = "admin" Then
strTable = strTable & "" & Day(objDateDisplay) & " " Else strTable = strTable & Day(objDateDisplay) & " " End If If strEventText <> "" Then strTable = strTable & strEventText strEventText = "" End If Else If strEventText <> "" Then strTable = strTable & "" & Day(objDateDisplay) & "" strEventText = "" Else strTable = strTable & Day(objDateDisplay) End If End If strTable = strTable & " | " & VbCrLf
objDateDisplay = DateAdd("d", 1, objDateDisplay)
End If
intDateCount = intDateCount + 1
Next
strTable = strTable & "||||||||||