<% Option Explicit Response.Buffer = True Response.Expires = 0 On Error Resume Next '************************************************************************************** '* 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. '************************************************************************************** '*** Declare the global variables *** Dim strMonth ' Array string for months Dim objDate ' Object for the Calendar Date Dim intStartDay ' starting day of Calendar Dim strFileName ' name of ASP files ' if you edit the strFileName variable, be sure to edit the .asp file to match strFileName = "index.asp" ' name of the webpage displaying the calendar '*** Check for Administration View *** If GetRequest("action") = "admin" Then strFileName = "admin.asp" ' name of the webpage displaying the administration calendar End If '*** Set the Month string array and Date Object *** strMonth = Array("","","","","","","","","","","","") Dim m For m = 0 To 11 strMonth(m) = MonthName(m + 1) Next '*** Use if you want to hard code months *** 'strMonth = Array("January","February","March","April","May","June","July","August","September","October","November","December") objDate = Date '*** Set the Beginning Day of the Calendar *** '*** 1-Sunday, 2-Monday, ..., 7-Saturday *** intStartDay = 1 '*** Check for user input data *** If GetRequest("date") <> "" Then objDate = CDate(GetRequest("date")) ElseIf GetRequest("month") <> "" And GetRequest("year") <> "" Then objDate = CDate(GetRequest("month") & "/" & GetRequest("year")) End If If GetRequest("day") <> "" Then intStartDay = CInt(GetRequest("day")) End If If GetRequest("logoff") = "yes" Then Session.Abandon Response.Redirect "./index.asp" End If Dim objConn Dim objCommand Dim objRS Dim objRS_view '******** create connection objects for data ******** Set objConn = Server.CreateObject("ADODB.Connection") Set objCommand = Server.CreateObject("ADODB.Command") '************************************************************************ '******** EDIT THE LINE BELOW IF YOU INSTALL TO A DIFFERENT PATH ******** '******** connection for an Access 2000 database ******** objConn.Open "Data Source=" & Server.Mappath("/ActionCalendar/events.mdb") & ";Provider=Microsoft.Jet.OLEDB.4.0;" '******** connection for an Access 97 database ******** 'objConn.Open "DBQ=" & Server.Mappath("/ActionCalendar/events_97.mdb") & ";Driver={Microsoft Access Driver (*.mdb)};" '************************************************************************ objCommand.ActiveConnection = objConn '******** get event data ******** If GetRequest("user_admin") = "" Then objCommand.CommandText = "select * from Event_Tbl where" &_ " event_month in (0," & Month(objDate) & ")" &_ " and event_year in (0," & Year(objDate) & ")" &_ " order by event_day" Set objRS = objCommand.Execute If GetRequest("view") = "yes" And GetRequest("admin_action") = "" Then objCommand.CommandText = "select * from Event_Tbl where" &_ " event_month in (0," & Month(GetRequest("date")) & ")" &_ " and event_day = " & Day(GetRequest("date")) &_ " and event_year in (0," & Year(GetRequest("date")) & ")" &_ " or event_weekday = " & WeekDay(GetRequest("date")) &_ " or event_id = " & GetRequest("event_id") Set objRS_view = objCommand.Execute ElseIf GetRequest("view") = "yes" And GetRequest("admin_action") = "edit" Then objCommand.CommandText = "select * from Event_Tbl where" &_ " event_id = " & GetRequest("event_id") Set objRS_view = objCommand.Execute End If End If '************************************************************************************** '* Function Name: GetView() * '* Input: Any valid date string. * '* Output: Recordset data matching the input date * '* Sample Call: string = GetView(10/12/01) 'gets the events for Oct. 12th 2001 * '************************************************************************************** Function GetView(srcDate) Dim strView,dwStripe Do While objRS_view.EOF <> True if dwStripe = "#ffffff" then dwStripe = "#f5f5eb" else dwStripe = "#ffffff" end if strView = strView & " • " & objRS_view("event_data") & "" & Chr(13) objRS_view.MoveNext Loop Set objRS_view = Nothing GetView = strView End Function '************************************************************************************** '* Function Name: GetRequest() * '* Input: Any valid string name. * '* Output: Value of matching Request collection. Looks for QueryString first, * '* then Form. * '* Sample Call: string = GetRequest("month") 'gets the 'month' input value * '************************************************************************************** Function GetRequest(name) If Request.QueryString(name) <> "" Then GetRequest = Request.QueryString(name) Else GetRequest = Request.Form(name) End If End Function '************************************************************************************** '* Function Name: GetPrint() * '* Input: Any valid date expression. * '* Output: Listing of all events for the current month of the calendar view. * '* Sample Call: string = GetPrint() * '************************************************************************************** Function GetPrint(srcDate) Dim strPrint, strEvent, i strPrint = "
" & VbCrLf &_ "" & VbCrLf &_ "
Events for " & MonthName(Month(GetRequest("date"))) & " - " & Year(GetRequest("date")) & "
" & VbCrLf For i = 1 To Day(DateAdd("d",-1,DateAdd("m",1,Month(srcDate) & "/01/" & Year(srcDate)))) strEvent = GetEvent(Month(srcDate) & "/" & i & "/" & Year(srcDate)) If strEvent <> "" Then strEvent = "" & Month(srcDate) & "/" & i & " : " & Replace(strEvent,VbCr,"
") End If strPrint = strPrint & strEvent strEvent = "" Next strPrint = strPrint & "
" & VbCrLf GetPrint = strPrint End Function '************************************************************************************** '* Function Name: GetEvent() * '* Input: Any valid date expression. * '* Output: HTML string with event information. * '* Sample Call: string = GetEvent(Date) 'gets today's events * '* string = GetEvent("10/10/1999") 'gets the events for Oct. 10, 1999 * '************************************************************************************** Function GetEvent(srcDate) '*** Declare the function variables *** Dim strEvent ' HTML string of event data Dim intEventDay ' counter check for each day Dim intEventWeekDay ' counter check for each day Dim strEventEndDate ' event duration check Dim strEventStartDate ' date event starts If objRS.EOF <> True Then intEventDay = objRS("event_day") intEventWeekDay = objRS("event_weekday") strEventEndDate = objRS("event_end_date") strEventStartDate = objRS("date_updated") Do While Not objRS.EOF = True If intEventDay = Day(srcDate) Or intEventWeekDay = WeekDay(srcDate) Then strEvent = strEvent & objRS("event_data") If GetRequest("action") = "admin" And (Session("ActiveUser") = objRS("user_id") Or Session("ActiveUserLevel") >= "700") Then strEvent = strEvent & "
edit" &_ " delete" End If strEvent = strEvent & "

" If strEventEndDate <> "" Then If DateDiff("d",srcDate,strEventStartDate) > 0 Then strEvent = "" End If If DateDiff("d",srcDate,strEventEndDate) < 0 Then strEvent = "" End If End If End If objRS.MoveNext If objRS.EOF <> True Then intEventDay = objRS("event_day") intEventWeekDay = objRS("event_weekday") strEventEndDate = objRS("event_end_date") strEventStartDate = objRS("date_updated") End If Loop objRS.MoveFirst End If GetEvent = strEvent End Function '************************************************************************************** '* Function Name: BuildDropDown() * '* Input: Any valid date expression, valid string * '* Output: HTML string with month, day or year select box * '* User Edits: None. Unless you change the range of years. * '* * '* Sample Call: string = BuildDropDown(Date,"month") 'gets month drop down list * '* string = BuildDropDown(Date,"year") 'gets year drop down list * '************************************************************************************** Function BuildDropDown(srcDate,strType) Dim strHTML Dim i Dim j strHTML = "" & VbCrLf BuildDropDown = strHTML End Function %>