var appConfig = getAppConfig();
var retQry = QueryNew("temp");
var dateRangeStruct = StructNew();
var filterData = StructNew();
var startDate = "";
var endDate = "";
var useVerboseOutput = false;
// Process the selected dates from the request.params and setup the request.ptCalendar date struct
var selectedDates = processSelectedDate();
if ( structKeyExists(appConfig,"enableVerboseOutput") AND LEN(TRIM(appConfig['enableVerboseOutput'])) )
useVerboseOutput = appConfig['enableVerboseOutput'];
// Get dateRange based on viewRangeType
dateRangeStruct = application.ptCalendar.calEventsService.getDateRangefromRangeType(dateRangeType=arguments.viewRangeType);
if ( StructKeyExists(dateRangeStruct,"startDate") )
startDate = dateRangeStruct.startDate;
if ( StructKeyExists(dateRangeStruct,"endDate") )
endDate = dateRangeStruct.endDate;
// Display dates used to filter the events query (if verbose output is turned on)
if ( useVerboseOutput ) {
WriteOutput("(Start Date: #startDate#) (End Date: #endDate#)
");
}
// Get the Events from the getEvents methohd (either cached or uncached)
retQry = application.ptCalendar.calEventsDAO.getEvents(
startDate = startDate
,endDate = endDate
,useCache = useEventsCache
);
// Output Cache Status (if verbose output is turned on)
if ( useVerboseOutput ) {
application.ptCalendar.calEventsCacheService.renderCalendarCacheStatusHTML();
}
// Filtering from the Display Properties Local Custom Element
if ( ArrayLen(arguments.displayPropsArray) AND StructKeyExists(arguments.displayPropsArray[1],"values") ) {
// Get Filter Fields and Values to be used in the filterEvents method
filterData = application.ptCalendar.calEventsService.buildCleanFilterStruct(arguments.displayPropsArray[1].values);
if ( !StructIsEmpty(filterData) ) {
// Filter the query by fields and values from the display properties element
retQry = application.ptCalendar.calEventsService.filterEvents(eventsQuery=retQry,filterStruct=filterData);
if ( retQry.RecordCount AND useVerboseOutput ) {
WriteOutput("(Filtered: 1)
");
}
}
}
return retQry;