<%@ LANGUAGE=VBSCRIPT %> <%Option Explicit%> <% 'This MUST remain here because the server-side script in the include file redirects Response.Buffer = True %> Immaculate Conception School Calendar

Immaculate Conception School
One Washington Street, Newburyport, MA 01950 * (978) 465-7780

www.icsnewburyport.com
Home
 
School Calendar
Homework
What's for Lunch?
Sports Calendar
The Communicator
ICS Photo Album
Contact Us
Links
About ICS

 

[an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] <% ' 'EzEvents - Version 1.1 ' 'Written By: George Chastain ' Huntsville, Alabama ' Website: http://home.hiwaay.net/~georgech/ ' ' You are free to use this code for any purpose but please retain the author and copyright ' information. If you make any enhancements to this code, I would like to know about them. ' You can reach me through my website address above. ' ' Thank you. ' 'SOURCE FILE: DisplayCalendar.inc 'DESCRIPTION: This file supplies the code to generate the calendar for the current month. ' 'Modifications: ' '25 June 2001 Initial Creation '24 August 2001 Modified code to prevent display of left arrow (previous month) control ' if the calendar is displaying the first month of the current year. ' I never designed the application to support dates before that because I ' planned to use this application to display events scheduled in the future ' along with those that recently expired for reference. ' *************************************************************************************** ' *************************************************************************************** ' Begin declarations ' *************************************************************************************** ' *************************************************************************************** Dim strPageTitle ' The title of this page. Dim objConn ' Database connection object Dim objRecordset ' Database recordset object Dim strPath ' Path to database Dim strSQL ' SQL string Dim dDate ' Date we're displaying calendar for Dim todaydate ' Today's date Dim today ' The day portion of today's date. Dim todaymonth ' The month portion of today's date. Dim dtTempDate ' Used during calculations Dim dtExpireDate ' For cleaning old events. Dim strReturnPage ' The current Calendar View Dim strReturnMonth ' The month last viewed in the calendar Dim strReturnYear ' The year last viewed in the calendar Dim dtDay 'Stores the day for the date stored in dDate Dim dtMonth 'Stores the month for the date stored in dDate Dim dtYear 'Stores the year for the date stored in dDate Dim strReturnYearTmpArray Dim passedval 'passed category number strPageTitle="" strReturnPage="" strReturnYear="" strReturnMonth = Request.QueryString("ReturnMonth") strReturnYear = Request.QueryString("ReturnYear") passedval = Request.QueryString("cat") 'response.write "Passedval= " & passedval if passedval = "" then passedval = "1" end if dim objRS, strConnection,strq, caltitle Set objConn = Server.CreateObject("ADODB.Connection") 'strConnection = "DSN=users1" strConnection="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.Mappath("/Database/users.mdb") objConn.Open strConnection Set objRS = Server.Createobject("ADODB.Recordset") Set objRS.ActiveConnection= objConn strq = "select * from categories where CategoryID='" & passedval & "'" 'strq = "select * from usertable where username='newuser1'" 'response.write "strq = " & strq & "
" objRS.Open strq if objRS.EOF then caltitle="Invalid Category" else caltitle=objRS("CategoryName") 'response.write "invalid password
" 'response.write "userpassword = " & objRS("userpw") & "
" end if objConn.close Set objRS=Nothing Set objConn = Nothing 'Current design allows for the possibility that the ReturnYear query string is undefined, 'contains a number (the year), or it may contain a number with a "#" followed by a tag name 'to jump to within the page. However, although the browser interprets the "#..." as a tag 'to jump to, it does NOT remove that text from the end of the URL. So, when calling 'Request.QueryString() to obtain the value of ReturnYear, you may get the "#..." tacked on to 'the end. As a result, we have to have code to remove this from the value. ' if Len(strReturnYear & "") <> 0 then if InStr(1,strReturnYear,"#",1) > 0 then strReturnYearTmpArray = Split(strReturnYear,"#",-1,1) strReturnYear = strReturnYearTmpArray(0) end if end if strReturnPage="schoolcalendar.asp" ' The current Calendar View is the default (current month) view 'Find event database and connect. strPath = Server.MapPath(DATABASE) DBConnect(strPath ) 'Get all events. Set objRecordset = Server.CreateObject("ADODB.Recordset") 'objRecordset.Open "calendar", objConn, adOpenKeyset, adLockPessimistic , adCmdTable Set objRecordset.ActiveConnection= objConn strq = "select * from calendar order by Subject" 'strq = "select * from usertable where username='newuser1'" 'response.write "strq = " & strq & "
" objRecordset.Open strq ' ************************************************************************************************* ' ************************************************************************************************* ' Begin main body of Event Calendar APP ' ************************************************************************************************* ' ************************************************************************************************* ' Get today's date. todaydate = Date today= Day(todaydate ) todaymonth = Month(todaydate) ' See if the Month and Year passed into this page is a valid month/year. If IsDate(strReturnMonth & " " & "1, " & strReturnYear ) Then dDate = CDate(strReturnMonth & " " & "1, " & strReturnYear) Else ' Either there was not a month/year passed in or it was invalid. Set dDate to the current ' date. dDate = Date() End If ' Get the Day, Month and Year for the date stored in dDate. dtDay = Day(dDate) dtMonth = Month(dDate) dtYear = Year(dDate) strReturnYear = dtYear strReturnMonth = dtMonth 'Begin generating Event Calendar App Main Table Response.Write("" & vbCrLf) '[an error occurred while processing this directive] %> <% 'Begin Event Calendar App Main Table 2nd Row. This is the row that contains the output of the app. Response.Write(" " & vbCrLf) Response.Write(" " & vbCrLf) Response.Write("" & vbCrLf) Response.Write("
" & vbCrLf) Response.Write("" & vbCrLf) ' We want the padding/spacing the same for the content row as for the header row so it will look nice. Response.Write("" & vbCrLf) Response.Write("" & vbCrLf) Response.Write("
" & vbCrLf) 'Response.Write("" & vbCrLf) 'Response.Write("All past events will be deleted after " & -(EVENTEXPIRATIONPERIOD) & " days!
" & vbCrLf) 'Response.Write("" & vbCrLf) Response.Write("
" & vbCrLf) Response.Write("" & vbCrLf) %> [an error occurred while processing this directive] <% 'Begin generating month for the calendar. ' ******************************************************************************** ' ******************************************************************************** ' ********************************************************************************************* Dim iDaysInMonth ' How many days are in the month that is being generated? Dim iWeekdayMonthStartsOn ' What weekday does the month being generated start on? Dim iDayOfMonthIndex ' What Day of the Month are we on? Dim iColumnPosition ' What weekday column in the week row are we on? Dim iColWidth ' The width for each column. Variable according to day of week 'Get the number of days in the month stored in dDate. iDaysInMonth = GetDaysInMonth(Month(dDate), Year(dDate)) 'What weekday does the month stored in dDate start on? iWeekdayMonthStartsOn = GetWeekdayMonthStartsOn(Month(dDate), Year(dDate)) 'Generate client-side javascript to operate the pull-down selection boxes for the month 'and year that will be displayed in the month's calendar. Response.Write("" & vbCrLf) Response.Write("
" & vbCrLf) Response.Write("" & vbCrLf) ' Begin Calendar Table Header Row Response.Write(" " & vbCrLf) ' Calendar Table Header Row contains 3 Cells Response.Write(" " & vbCrLf) Response.Write(" " & vbCrLf) 'Generate weekend and weekday column headers. Response.Write(" " & vbCrLf) Response.Write(" " & vbCrLf) Response.Write(" " & vbCrLf) Response.Write(" " & vbCrLf) Response.Write(" " & vbCrLf) Response.Write(" " & vbCrLf) Response.Write(" " & vbCrLf) Response.Write(" " & vbCrLf) Response.Write(" " & vbCrLf) Response.Write("" & vbCrLf) 'Write empty columns for each day in the first row until we get to the day of the week that the 'month starts on. If iWeekdayMonthStartsOn <> 1 Then Response.Write(vbTab & "" & vbCrLf) iColumnPosition = 1 Do While iColumnPosition < iWeekdayMonthStartsOn Response.Write(vbTab & vbTab & "" & vbCrLf) iColumnPosition = iColumnPosition + 1 Loop End If '-- Write days of month in proper day slots -- iDayOfMonthIndex = 1 iColumnPosition = iWeekdayMonthStartsOn Do While iDayOfMonthIndex <= iDaysInMonth '-- open the table row -- If iColumnPosition = 1 Then Response.Write(vbTab & "" & vbCrLf) End If if iColumnPosition = 1 then iColWidth="12%" 'When printing Sunday column, make it 12% wide else if iColumnPosition = 7 then iColWidth="13%" 'When printing a weekday column, make it 13% wide else iColWidth="15%" 'When printing Saturday column, make it 15% wide. end if end if 'Write the day number, highlighting today's date if the current month is being shown. ' Is the current month equal to the month that was requested to be displayed? if (todaymonth = Month(dDate)) and (dtTodayYear = Year(dDate)) then 'Yes, the month requested for display IS the current month. 'Is the current day equal to today's date? if today <> iDayOfMonthIndex then 'No, we have to print a day that is another day of the current month Response.Write(vbTab & vbTab & "" & vbCrLf) ' Complete the first week row If iColumnPosition = 7 Then Response.Write vbTab & "" & vbCrLf iColumnPosition = 0 End If 'Increment calender row (week) and column (day) variables iDayOfMonthIndex = iDayOfMonthIndex + 1 iColumnPosition = iColumnPosition + 1 Loop 'Finish out the last row of the table with empty cells if the month does 'not end at the end of a row. If iColumnPosition <> 1 Then Do While iColumnPosition <= 7 Response.Write(vbTab & vbTab & "" & vbCrLf) iColumnPosition = iColumnPosition + 1 Loop Response.Write vbTab & "" & vbCrLf End If 'Close the month table Response.Write("
" & vbCrLf) Response.Write(" " & vbCrLf) Response.Write("" & vbCrLf) Response.Write(" " & vbCrLf) Response.Write(" " & vbCrLf) Response.Write(" " & vbCrLf) Response.Write(" " & vbCrLf) Response.Write(" " & vbCrLf) if caltitle = "Lunch" then Response.Write("" & vbCrLf) end if Response.Write("
" & caltitle & " Calendar
" & vbCrLf) '********************************************************************************** 'Fixed 24 August 2001 to disable left arrow if the calendar is showing the first month 'of the current year. if (Month(dDate) = 1) AND (Year(dDate) = Year(todaydate)) then Response.Write("" & vbCrLf) else Response.Write(" " & vbCrLf) end if '********************************************************************************** '********************************************************************************** Response.Write(" " & vbCrLf) Response.Write(" ") Response.Write(" ") Response.Write("
") '****************************************************************************** '****************************************************************************** 'Generate controls for selecting day, month and year for new event. 'Default the controls to today's date. Dim iIndex Dim dtToday ' Today's date Dim dtTodayYear ' Today's date year dtToday = Date dtTodayYear = Year(dtToday) Response.Write("" & vbCrLf) Response.Write("" & vbCrLf) ' Generate the pull-down selection box for the month field. Default the month to the month ' stored in dDate. Response.Write("" & vbCrLf) ' Generate the pull-down selection box for the year field. Default the year to the year ' stored in dDate. Response.Write("" & vbCrLf) Response.Write("
" & vbCrLf) Response.Write("" & vbCrLf) Response.Write("" & vbCrLf) Response.Write("" & vbCrLf) Response.Write("
" & vbCrLf) ' Display icon for the 12 month look-ahead option. Response.Write("
") Response.Write("
Lunch cost is $3.25, includes drink, fruit and dessert
Daily specials: pizza,hotdogs,pasta,cereal,muffins and salads
Per request on lunch slips
" & vbCrLf) Response.Write("
SunMonTueWedThuFriSat
 
" & iDayOfMonthIndex ) else 'Yes, we are printing today's date. Highlight the day number to highlight the today. Response.Write(vbTab & vbTab & "" & iDayOfMonthIndex & "") end if else 'No, the requested month to display is not the current month, print all days the same with 'no highlighting. Response.Write(vbTab & vbTab & "" & iDayOfMonthIndex ) end if '************************************************************************ ' Write the titles of all events that occur on the day being generated for the month calendar. Dim currentdDate ' Temporary variable to store serialized month/year of dDate. If Not objRecordset.BOF Then objRecordset.MoveFirst currentdDate = DateSerial(Year(dDate),Month(dDate),iDayOfMonthIndex) Do Until objRecordset.EOF if (currentdDate >= objRecordset.Fields("DateVal")) AND (currentdDate <= objRecordset.Fields("DateVal2")) then if (passedval = objRecordset.Fields("CategoryID")) then Response.Write("
" & objRecordset.Fields("Subject") & "") end if end if objRecordset.MoveNext Loop End If '************************************************************************ Response.Write("
 
" & vbCrLf) Response.Write("
" & vbCrLf) ' End generating Month ' ******************************************************************************** ' ******************************************************************************** ' ******************************************************************************** ' Check to see if autodelete of expired events is turned on. if ENABLEAUTODELETE = true then 'Prepare to clean old events from database dtExpireDate = DateAdd("d",EVENTEXPIRATIONPERIOD,todaydate) 'We must check the End Date of the event agains the current date to see if the event 'has technically expired and therefore must be deleted. strSQL = "DELETE FROM " & "calendar" & " WHERE DateVal2 < " & CDbl(dtExpireDate) end if 'Close and destroy connection and recordset objects. objConn.Execute(strSQL) objRecordset.Close Set objRecordset = Nothing DBClose Response.Write("" & vbCrLf) if ALLOWADD = true then Response.Write("" & vbCrLf) end if 'Response.Write("" & vbCrLf) Response.Write(""& vbCrLf) 'Response.Write("
" & vbCrLf) Response.Write("
" & vbCrLf) Response.Write(" " & "  ") Response.Write("
") Response.Write("
") 'Response.Write("") 'Response.Write("
" & vbCrLf) Response.Write(" " & "  ") Response.Write("
" & vbCrLf) 'Response.Write(" " & "  ") 'Response.Write("
" & vbCrLf) Response.Write("
" & vbCrLf) Response.Write("" & vbCrLf) Response.Write("All past events will be deleted after " & -(EVENTEXPIRATIONPERIOD) & " days!
" & vbCrLf) Response.Write("
" & vbCrLf) %> [an error occurred while processing this directive]