%
'===========================================================
' filename: calendar.asp =
' =
' purpose: this file displays the calendar =
' =
'===========================================================
'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
' make sure the path to the include file below is correct !!!!
'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
%>
<%
'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
'on error resume next
'===========================================================
' declarations =
'===========================================================
dim months, arrMonths, today, selectedMonth, selectedYear, daysOfWeek, arrDaysOfWeek
dim dayOne, firstDayOnCalendar, rs, id
if isNumeric(calendarID) and len(calendarID & "") > 0 then 'a specific template is requested
getTemplate() 'get template info for this calendar
end if
months = "January,February,March,April,May,June,July,August,September,October,November,December"
arrMonths = split(months, ",")
daysOfWeek = "Sun,Mon,Tue,Wed,Thur,Fri,Sat"
arrDaysOfWeek = split(daysOfWeek, ",")
today = cdate(datepart("m", now()) & "/" & datepart("d", now()) & "/" & datepart("yyyy", now()))
'============================================================================
'============================================================================
' ==================
' main body of program ==================
' ==================
'============================================================================
'============================================================================
'see if new month or year has been requested
selectedMonth = request("selectedMonth")
selectedYear = request("selectedYear")
'check to see if a new valid month or year has been requested so we can determine
'what month and year we are displaying
if not (selectedMonth < 13 and selectedMonth > 0) then
selectedMonth = datepart("m", today)
end if
if not (selectedYear < (year(now())+50) or selectedYear > (year(now())-50)) or len(selectedYear & "") = 0 then
selectedYear = datepart("yyyy", today)
end if
'get first day of selected month
firstDayOfMonth = selectedMonth & "/1/" & selectedYear
firstDayOnCalendar = dateAdd("d", cdate(firstDayOfMonth), (dayOne * -1)+1)
dayOne = datepart("w", cdate(selectedMonth & "/1/" & selectedYear))
'------------------------------------------------------------------------------------------------------------
'debug
'Response.Write "date = " & selectedMonth & "/1/" & selectedYear & "
"
'Response.Write dayOne & "
"
firstDayOnCalendar = dateAdd("d", cdate(firstDayOfMonth), (dayOne * -1)+1)
'Response.Write firstDayOnCalendar & "
"
'------------------------------------------------------------------------------------------------------------
displayStyles() 'style sheet for calendar
displayCalendarHeader() 'displays calendar header
displayCalendar() 'display the calendar
'============================================================================
'============================================================================
' ==================
' end main body of program ==================
' ==================
'============================================================================
'============================================================================
'.......................................................................................................
'.......................................................................................................
'.......................................................................................................
'.......................................................................................................
'===========================================================............................................
' Below are thu functions and subroutines that drive this =............................................
' page. =............................................
'===========================================================............................................
'.......................................................................................................
'.......................................................................................................
'.......................................................................................................
'.......................................................................................................
'++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
'++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
'***********************************************************
' subroutine: displayStyles() *
' *
' purpose: displays style sheet for calendar *
' *
' parameters: none *
' *
'***********************************************************
sub displayStyles()
%>
<%
end sub
'++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
'++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
'***********************************************************
' subroutine: displayCalendarHeader() *
' *
' purpose: displays the calendar header (month, year, *
' forward, and back links) *
' *
' parameters: none *
' *
'***********************************************************
sub displayCalendarHeader()
dim thisPage, thisQuery, prevMonth, prevYear, nextMonth, nextYear, prevNewYear, nextNewYear, borderStyle
thisPage = Request.ServerVariables("Script_Name") 'name of current page
thisQuery = Request.ServerVariables("Query_string")
select case selectedMonth 'determine previous and next month and year for calendar links
case 1 'January
prevMonth = 12
nextMonth = 2
prevNewYear = selectedYear - 1
nextNewYear = selectedYear
case 12 'December
prevMonth = 11
nextMonth = 1
prevNewYear= selectedYear
nextNewYear= selectedYear + 1
case else 'All other months
prevMonth = selectedMonth - 1
nextMonth = selectedMonth + 1
prevNewYear= selectedYear
nextNewYear= selectedYear
end select
prevYear = selectedYear - 1
nextYear = selectedYear + 1
borderStyle = "BORDER-RIGHT: " & daysBorderColor & " 1px solid; BORDER-TOP: " & daysBorderColor & " 1px solid; BORDER-LEFT: " & daysBorderColor & " 1px solid; "
%>
| << | < | <%=arrMonths(selectedMonth-1) & " " & selectedYear%> | > | >> |
| <%=arrDaysOfWeek(i)%> | <% Next %>
|
<%=day(thisDay)%>
<% getEvents(thisDay) 'get any events for that day %> |
<%
thisDay = thisDay + 1
next
%>