<% ' Copyright 1999 Jason Abbott (jason@webott.com) ' Last updated 06/29/1999 dim dayFirst, dayLast, d, cal, col, description, row dim events(31), rowCurrent, rowTotal, m, y, mLoop, yLoop dim datePrev, dateNext, userID, index if Request.Form("logout") = "Logout" OR _ Session(dataName & "User") = "" then Session(dataName & "User") = 0 Session(dataName & "Public") = 1 Session(dataName & "Access") = "" end if if Request.Form("public") = "Hide public events" then Session(dataName & "Public") = 0 elseif Request.Form("public") = "Show public events" then Session(dataName & "Public") = 1 elseif Session(dataName & "Public") = "" then Session(dataName & "Public") = 1 end if ' --------------------------------------------------------- ' setup values ' --------------------------------------------------------- ' determine how this page was called and assign values ' for month and year accordingly if Request.Form("month") <> "" then m = CDbl(Request.Form("month")) y = CDbl(Request.Form("year")) elseif Request.QueryString("date") <> "" then m = Month(Request.QueryString("date")) y = Year(Request.QueryString("date")) else m = Month(Date) y = Year(Date) end if dateNext = DateAdd("m", 1, DateSerial(y, m, 1)) datePrev = DateAdd("m", -1, DateSerial(y, m, 1)) ' --------------------------------------------------------- ' build an array of event data for selected month ' --------------------------------------------------------- ' find the numeric value of the first day of the month ' ie Sunday = 1, Wednesday = 4 dayFirst = WeekDay(Dateserial(y, m, 1)) ' find the last day by subtracting 1 day from the first day ' of the next month (no need for yNext here) dayLast = Day(Dateserial(y, Month(dateNext), 1) - 1) ' now get the total for last month to write the few ' days of last month that show up on this calendar dayLastMonth = Day(Dateserial(y, m, 1) - 1) ' find all events occuring between the first and ' last second of the selected month query = "SELECT * FROM cal_events E INNER JOIN cal_dates D" _ & " ON (E.event_id = D.event_id) " _ & " WHERE event_date BETWEEN " & strDelim _ & m & "/1/" & y & strDelim _ & " AND " & strDelim & m & "/" & dayLast & "/" & y _ & strDelim & " AND (user_id = " & Session(dataName & "User") if Session(dataName & "Public") then query = query & " OR private = 0)" else query = query & " AND private = 1)" end if query = query & " ORDER BY event_date, time_start" ' put all matching events in an array indexed by day number %> <% ' &H0001 (hex 1), which is adCmdText, tells the ' connection object that we're sending a text command, ' which is speedier Set rs = db.Execute(query,,&H0001) 'response.write query do while not rs.EOF index = Day(rs("event_date")) events(index) = events(index) _ & "" & VbCrLf _ & " "" then description = Replace(TimeValue(rs("time_start")), ":00 ", " ") _ & " to " & Replace(TimeValue(rs("time_end")), ":00 ", " ") else description = "Click for more details" end if events(index) = events(index) _ & showStatus(description) & ">" _ & rs("event_title") & "
" & VbCrLf rs.movenext loop rs.Close db.Close set rs = nothing set db = nothing %>
>Previous month   <%=MonthName(m) & " " & y%>   >Next month
Jump to date:
>Goto the selected date
<% ' print all the day names as headings for col = 1 to 7 response.write " " & VbCrLf next response.write "" ' --------------------------------------------------------- ' now generate calendar body ' --------------------------------------------------------- ' the column variable keeps constant track of the ' current calendar column column = 0 font = "" nondayFormat = "" & VbCrLf column = column + 1 next ' now cycle through all the days of the current month row = 1 for d = 1 to dayLast column = column + 1 response.write "" & VbCrLf if column = 7 AND d < dayLast then response.write "" & VbCrLf column = 0 row = row + 1 end if next ' finally, cycle through as many days of the next month as ' necessary to fill the calendar grid through column 7 if column > 0 then d = 1 do while column < 7 response.write nondayFormat & d & "" & VbCrLf d = d + 1 column = column + 1 loop response.write "" end if %>
" _ & VbCrLf & "" _ & WeekDayName(col,0) & "
" & font & "" & VbCrLf ' cycle through all the days previous to the first ' day of the active month for d = 1 to dayFirst - 1 response.write nondayFormat & dayLastMonth - dayFirst + d + 1 _ & "" & font & VbCrLf _ & VbCrLf & "" & d & "
" _ & "" _ & events(d) & "
" _ & "
<% end if %>
<% if Session(dataName & "User") = 0 then ' accomodate virtual host (jea:3/8/00) strPath = Request.ServerVariables("PATH_TRANSLATED") strPath = Right(strPath, Len(strPath) - InStrRev(strPath,"\")) response.write "
>
<% elseif Session(dataName & "Access") = "admin" then %>
<% end if%>
<% if Session(dataName & "User") <> 0 then %>
<% if Session(dataName & "Public") then %> <% else %> <% end if %>


Sponsored by Gualala.com