appName = application.ptCalendar.getAppBeanName();
appConfig = application.ptCalendar.getAppConfig();
// Set the Event Cache status from the configuration element
//useEventsCache = application.ptCalendar.getEventCacheStatus();
// - EventsCache Override (the search form should search LIVE data)
useEventsCache = false;
// Set the UI theme from the Configuration Element
uiTheme = application.ptCalendar.getUItheme();
useVerboseOutput = application.ptCalendar.getVerboseOutputStatus();
editDisplayType = "Datasheet"; // (DataSheet/Grid)
// date/time defualt values from the Confing
dayBeginTime = application.ptCalendar.getDayBeginTime();
dayEndTime = application.ptCalendar.getDayEndTime();
// date format values from the Confing
cfDateFormatMask = application.ptCalendar.getDisplayCFdateMask();
jsDateFormatMask = application.ptCalendar.getDatePickerJSdateMask();
// Orgs and Cats Sort Field from the Confing
orgsFilterSortField = application.ptCalendar.getOrgsDisplaySortField();
catsFilterSortField = application.ptCalendar.getCatsDisplaySortField();
// Default Field Values
defaultApprovalStatus = ""; //Approved
defaultStartDate = "";
defaultEndDate = "";
defaultRangeType = "m"; // m - month, d - day, y - year, ww - week
defaultRangeQty = "2";
defaultMonth = "";
defaultYear = "";
// Set a Dummy UUID so the DataSheet filter doesn't fail
dummyEventID = "XXXXXXXX-AAAA-YYYY-ZZZZZZZZZZZZZZZZ";
eventsfilterData = StructNew();
eventsfilterIDlist = "";
eventsfilterStatus = false;
// Get the Edit Display type from the attributes passed in from the Custom Script Element ATTRIBUTES
if ( StructKeyExists(attributes,"editType") )
editDisplayType = attributes.editType;
// Set up eventManager request variable if it doesn't exist'
if ( !StructKeyExists(request,"ptCalendar") )
request.ptCalendar = StructNew();
if ( !StructKeyExists(request.ptCalendar,"eventManager") )
request.ptCalendar.eventManager = StructNew();
if ( !StructKeyExists(request.ptCalendar.eventManager,"eventIDlist") )
request.ptCalendar.eventManager.eventIDlist = dummyEventID; // Use a Dummy UUID so the DataSheet filter doesn't fail
cachedfilters = StructNew();
// Check to see if SEARCH button was clicked
if ( NOT StructKeyExists(request.params,"dsFilterAction") ) {
// See if there are any filters stored in session
cachedfilters = application.ptCalendar.calEventsSearchController.readFilterSessionVars(filterType=editDisplayType);
if ( StructKeyExists(cachedfilters,"dsFilterAction") ) {
// Add the cached filters to the request.params
StructAppend(request.params,cachedfilters);
}
}
else if ( request.params.dsFilterAction EQ "reset" ) {
application.ptCalendar.calEventsSearchController.clearFilterSessionVars(filterType=editDisplayType);
}
// Build the eventsfilterIDlist
if ( StructKeyExists(request.params,"eventID") ) {
// if a list if IDs has been passed in via the URL go ahead a override any other criteria
eventsfilterIDlist = request.params.eventID;
}
else if ( StructKeyExists(request.params,"dsFilterAction") AND request.params.dsFilterAction EQ "search" ) {
//useEventsCache = false; // Use this to override the appCofig setting when debugging
// if the searchFilterForm has been submitted process the submission and return a list of eventIDs
// or a query with the calEventIDs as a column and use the ValueList() function
eventsfilterResult = application.ptCalendar.calEventsSearchController.processEventsManagerFilterForm(
filterCriteria=request.params
,filterType=editDisplayType
,useCache = useEventsCache
);
// Copy the filterCriteria from request.params (URL) vars to session scope
application.ptCalendar.calEventsSearchController.createFilterSessionVars(filterCriteria=request.params,filterType=editDisplayType);
}
else {
//useEventsCache = false; // Use this to override the appCofig setting when debugging
// Get Default Start and End Date... if Datasheet View
if ( editDisplayType EQ "Datasheet" ) {
defaultStartDate = CreateDate(Year(Now()), Month(Now()), 1);
//defaultStartDate = Now();
defaultStartDate = DateFormat(defaultStartDate,cfDateFormatMask);
defaultEndDate = DateFormat(DateAdd(defaultRangeType,defaultRangeQty,defaultStartDate),cfDateFormatMask);
}
else {
defaultMonth = Month(Now());
defaultYear = Year(Now());
}
defaultCriteria = StructNew();
defaultCriteria.dsFilterStartDate = defaultStartDate;
defaultCriteria.dsFilterEndDate = defaultEndDate;
defaultCriteria.dsFilterMonth = defaultMonth;
defaultCriteria.dsFilterYear = defaultYear;
defaultCriteria.dsFilterApprovedStatus = defaultApprovalStatus;
//application.ptCalendar.utils.doDump(defaultCriteria,"defaultCriteria",0);
// Build default list of event IDs to display with ONLY date criteria
eventsfilterResult = application.ptCalendar.calEventsSearchController.processEventsManagerFilterForm(filterCriteria=defaultCriteria,filterType=editDisplayType,useCache = useEventsCache);
}
if ( StructKeyExists(eventsfilterResult,"filterIDlist") AND LEN(TRIM(eventsfilterResult.filterIDlist)) )
eventsfilterIDlist = eventsfilterResult.filterIDlist;
if ( StructKeyExists(eventsfilterResult,"filterStatus") )
eventsFilteredStatus = eventsfilterResult.filterStatus;
if ( LEN(TRIM(eventsfilterIDlist)) )
request.ptCalendar.eventManager.eventIDlist = eventsfilterIDlist;
// Get the URL for the current page
currentPageID = request.page.id;
currentPageURL = application.ptCalendar.csData.getCSPageURL(currentPageID);
// Set the default URL from the search form
formActionURL = "#currentPageURL#";
formActionParams = "";
if ( StructKeyExists(cgi,"QUERY_STRING") AND LEN(TRIM(cgi.QUERY_STRING)) )
formActionParams = cgi.QUERY_STRING;
submitStatusHTML = " Searching...";
clearStatusHTML = " Resetting...";
showToolsLinkText = "Show Search Filters";
hideToolsLinkText = "Hide Search Filters";
// Filter field size defaults
dateFieldSize = "10";
dateMaxSize = "12";
textFieldSize = "20";
textMaxSize = "255";
// Filter Form Defaults
selectedApprovedStatus = defaultApprovalStatus;
selectedKeywords = "";
selectedStartDateValue = defaultStartDate;
selectedEndDateValue = defaultEndDate;
selectedCategories = "";
selectedOrganizations = "";
selectedLocation = "";
selectedMonth = defaultMonth;
selectedYear = defaultYear;
if ( StructKeyExists(request.params,"dsFilterStartDate") )
selectedStartDateValue = request.params.dsFilterStartDate;
if ( StructKeyExists(request.params,"dsFilterEndDate") )
selectedEndDateValue = request.params.dsFilterEndDate;
if ( StructKeyExists(request.params,"dsFilterCategories") )
selectedCategories = request.params.dsFilterCategories;
if ( StructKeyExists(request.params,"dsFilterOrganizations") )
selectedOrganizations = request.params.dsFilterOrganizations;
if ( StructKeyExists(request.params,"dsFilterLocation") )
selectedLocation = request.params.dsFilterLocation;
if ( StructKeyExists(request.params,"dsFilterKeywords") )
selectedKeywords = request.params.dsFilterKeywords;
if ( StructKeyExists(request.params,"dsFilterApprovedStatus") )
selectedApprovedStatus = request.params.dsFilterApprovedStatus;
if ( StructKeyExists(request.params,"month") AND IsNumeric(request.params.month) ) {
//TODO: Add in the month browsing links
selectedMonth = request.params.month;
}
else if ( StructKeyExists(request.params,"dsFilterMonth") AND IsNumeric(request.params.dsFilterMonth) ) {
selectedMonth = request.params.dsFilterMonth;
//request.ptCalendar.thisMonth = selectedMonth;
//request.ptCalendar.thisDay = 1;
// Simulate month browsing links
request.params.month = selectedMonth;
request.params.clicked = 1;
}
else {
request.params.month = selectedMonth;
request.params.clicked = 1;
}
if ( StructKeyExists(request.params,"year") AND IsNumeric(request.params.year) ) {
//TODO: Add in the month browsing links
selectedYear = request.params.year;
}
else if ( StructKeyExists(request.params,"dsFilterYear") AND IsNumeric(request.params.dsFilterYear) ) {
selectedYear = request.params.dsFilterYear;
//request.ptCalendar.thisYear = selectedYear;
//request.ptCalendar.thisDay = 1;
// Simulate year browsing links
request.params.year = selectedYear;
request.params.clicked = 1;
}
else {
request.params.year = selectedYear;
request.params.clicked = 1;
}
// Get the Active Organization
orgArray = application.ptCalendar.calOrganizationsDAO.getCalOrgIDandNameArray(activeOnly=1,sortField=orgsFilterSortField);
// Get the Active Categories for the selected Org
catArray = application.ptCalendar.calEventCategoriesDAO.getFilteredCategoriesByOrgID(orgID=selectedOrganizations,filterField="active",filterValue=1,sortField=catsFilterSortField);
// Get the Locations list from the Event Details Records
locationsQry = application.ptCalendar.calEventDetailsDAO.getUniqueLocationsQuery();
application.ptCalendar.scripts.loadJQuery();
application.ptCalendar.scripts.loadJQueryUI(themeName=uiTheme);
application.ptCalendar.scripts.loadJQuerySelectboxes();
// load headers for jQuery Cookie
application.ptCalendar.scripts.loadJQueryCookie();
// Load the DateJS Plugin Headers
application.ptCalendar.scripts.loadDateJS();
// Load the BBQ Plugin Headers
application.ptCalendar.scripts.loadJQueryBBQ();
// Load the CFJS Plugin Headers
application.ptCalendar.scripts.loadCFJS();
// load header for the Calendar Admin CSS
application.ptCalendar.calService.loadCalendarAdminCSS();
// Output Cache Status (if verbose output is turned on)
if ( useVerboseOutput ) {
application.ptCalendar.calEventsCacheService.renderCalendarCacheStatusHTML(eventsCacheStatusOverride=useEventsCache);
}