TodayDate = CreateODBCDate(Now());
SELECT Org, Name, Location, Eventdate, Detail, ID, Type FROM events
WHERE Eventdate > #TodayDate#
ORDER BY Eventdate
ASC
Repeat1_NumRows = 6;
events_NumRows = events_NumRows + Repeat1_NumRows;
// *** Recordset Stats, Move To Record, and Go To Record: set stats variables
// set the record count
events_total = events.RecordCount;
// set the number of rows displayed on this page
If (events_NumRows LT 0 OR events_NumRows GTE events_total) {
events_NumRows = events_total;
} Else If (events_NumRows EQ 0) {
events_NumRows = 1;
}
// set the first and last displayed record
events_first = Min(1, events_total);
events_last = Min(events_NumRows, events_total);
MM_paramName = "";
// *** Move To Record and Go To Record: declare variables
MM_rs = events;
MM_rsCount = events_total;
MM_size = events_NumRows;
MM_uniqueCol = "";
MM_paramName = "";
MM_offset = 1;
MM_atTotal = false;
MM_paramIsDefined = false;
If (MM_paramName NEQ "") MM_paramIsDefined = IsDefined(MM_paramName);
// *** Move To Record: handle 'index' or 'offset' parameter
If (NOT MM_paramIsDefined AND MM_rsCount NEQ 0) {
// use index parameter if defined, otherwise use offset parameter
If (IsDefined("index")) {
MM_offset = index;
} Else If (IsDefined("offset")) {
MM_offset = offset;
}
// check if we are past the end of the recordset
If (MM_offset GT MM_rsCount OR MM_offset EQ 0) { // past end or move last
If ((MM_rsCount MOD MM_size) NEQ 0) { // last page not a full repeat region
MM_offset = MM_rsCount - (MM_rsCount MOD MM_size) + 1;
} Else {
MM_offset = MM_rsCount - MM_size + 1;
}
}
}
// *** Move To Record: replace the current query, for navigation on a detail page
If (MM_size EQ 1) { // if no repeated regions are defined
// create a new query with one row
MM_newQuery = QueryNew(MM_rs.ColumnList);
QueryAddRow(MM_newQuery, 1);
// copy the data in the row pointed to by MM_offset to the new query
MM_columns = ListToArray(MM_rs.ColumnList,",");
For (i=1; i LTE ArrayLen(MM_columns); i=i+1) {
QuerySetCell(MM_newQuery, MM_columns[i], MM_rs[MM_columns[i]][MM_offset], 1);
}
// change the recordset to be only this one row
events = MM_newQuery;
}
// *** Move To Record: update recordset stats
// set the first and last displayed record
events_first = Min(MM_offset, MM_rsCount);
events_last = Min(MM_offset + MM_size - 1, MM_rsCount);
// set the starting index for repeated regions on this recordset
events_Index = MM_offset;
// set the boolean used by hide region to check if we are on the last record
MM_atTotal = (MM_offset + MM_size - 1 GTE MM_rsCount);
// *** Go To Record and Move To Record: create strings for maintaining URL and Form parameters
// create the list of parameters which should not be maintained
MM_removeList = "&index=";
If (MM_paramName NEQ "") MM_removeList = MM_removeList & "&" & MM_paramName & "=";
MM_keepURL=""; MM_keepForm=""; MM_keepBoth=""; MM_keepNone="";
// add the existing URL parameters to the MM_keepURL string
MM_params=ListToArray(CGI.QUERY_STRING,"&");
For (i=1; i LTE ArrayLen(MM_params); i=i+1) {
If (FindNoCase("&" & GetToken(MM_params[i],1,"=") & "=",MM_removeList) Is 0)
MM_keepURL = MM_keepURL & "&" & MM_params[i];
}
// add the existing Form variables to the MM_keepForm string
If (IsDefined("FORM.FieldNames")) {
MM_params=ListToArray(FORM.FieldNames,",");
For (i=1; i LTE ArrayLen(MM_params); i=i+1) {
If (FindNoCase("&" & MM_params[i] & "=",MM_removeList) Is 0)
MM_keepForm = MM_keepForm & "&" & LCase(MM_params[i]) & "=" & URLEncodedFormat(Evaluate("FORM." & MM_params[i]));
}
}
// create the Form + URL string and remove the intial '&' from each of the strings
MM_keepBoth = MM_keepURL & MM_keepForm;
If (MM_keepURL NEQ "") MM_keepURL = RemoveChars(MM_keepURL,1,1);
If (MM_keepForm NEQ "") MM_keepForm = RemoveChars(MM_keepForm,1,1);
If (MM_keepBoth NEQ "") MM_keepBoth = RemoveChars(MM_keepBoth,1,1);
// *** Move To Record: set the strings for the first, last, next, and previous links
MM_keepMove = MM_keepBoth;
MM_moveParam = "index";
// if the page has a repeated region, remove 'offset' from the maintained parameters
if (MM_size GT 1) {
MM_moveParam = "offset";
MM_params = ListToArray(MM_keepMove,"&");
MM_keepMove = "";
For (i=1; i LTE ArrayLen(MM_params); i=i+1) {
If (CompareNoCase(GetToken(MM_params[i],1,"="),MM_moveParam) IS NOT 0) {
MM_keepMove = MM_keepMove & "&" & MM_params[i];
}
}
If (MM_keepMove NEQ "") {
MM_keepMove = RemoveChars(MM_keepMove,1,1);
}
}
// set the strings for the move to links
if (MM_keepMove NEQ "") MM_keepMove = MM_keepMove & "&";
urlStr = CGI.SCRIPT_NAME & "?" & MM_keepMove & MM_moveParam & "=";
MM_moveFirst = urlStr & "1";
MM_moveLast = urlStr & "0";
MM_moveNext = urlStr & (MM_offset + MM_size);
MM_movePrev = urlStr & Max(MM_offset-MM_size,1);
WI - Events Calendar