variables.eventStepLogging = false;
var retHTML = "";
var appConfig = getAppConfig();
var uiTheme = getUItheme();
var editBean = "calEventsForms";
var editMethod = "renderEventEditForm";
var editTitle = "Edit Event";
var callbackAction = "updateEventCache_cbFunct";
var callbackActionID = "";
var eventDataPageID = "";
var newCalEventID = "";
var createEventStruct = StructNew();
var dataStruct = StructNew();
var noIDMsg = "";
var logMsg = "";
var logProcess = "Edit-Event";
//arguments.appDebug = true;
if ( variables.eventStepLogging )
doStepLogging(processName=logProcess,methodName="calEventsConfirmController.processEditConfirmForm",logMsg="",addBreak=false);
// Edit / Create an occurrence of the event
if ( arguments.editSeriesOption EQ "occurrence")
{
if ( LEN(TRIM(arguments.dateTimeID)) AND LEN(TRIM(arguments.hashID)) )
{
// If the event has both DateTimeID and a HashID
// - Do NOT create an event Exception (one already exists)
// - Use the parent DataPageID and open the specific occurrence in the edit event form
// - - For this case the arguments.parentDataPageID is VALID
// - - It is the DataPageID for the Event Details of the Event Exception
editTitle = "Edit the Event Occurrence";
// If we are editing the SERIES... then use the Parent (or Group) datapageID from the Main event and just display the edit Event form
if ( StructKeyExists(arguments,"occurrDataPageID") AND IsNumeric(arguments.occurrDataPageID) AND arguments.occurrDataPageID GT 0 )
eventDataPageID = arguments.occurrDataPageID;
if ( LEN(TRIM(arguments.occurrEventID)) )
callbackActionID = arguments.occurrEventID;
}
else if ( LEN(TRIM(arguments.dateTimeID)) )
{
// If the event has ONLY an arguments.dateTimeID value
// - This is from a static date/time event
// - This should NOT occur but if it does just open the form
// - Do NOT create an event Exception
editTitle = "Edit the Event";
if ( StructKeyExists(arguments,"occurrDataPageID") AND IsNumeric(arguments.occurrDataPageID) AND arguments.occurrDataPageID GT 0 )
eventDataPageID = arguments.occurrDataPageID;
}
else if ( LEN(TRIM(arguments.hashID)) )
{
// If editing the occurrence of the event... create the recurrence exception event and then display the edit form
// Create the recurrence exception event
// - add the dtHashID to the parent event
// - return with a datapageid of the new event
createEventStruct = createExceptionEvent(
hashID=TRIM(arguments.hashID)
);
// Open the edit form of the new Event using its dataPageID
if ( StructKeyExists(createEventStruct,"newDataPageID") )
eventDataPageID = createEventStruct.newDataPageID;
if ( StructKeyExists(createEventStruct,"newCalEventID") )
newCalEventID = createEventStruct.newCalEventID;
if ( LEN(TRIM(arguments.seriesEventID)) )
callbackActionID = arguments.seriesEventID;
if ( LEN(TRIM(newCalEventID)) )
callbackActionID = ListAppend(callbackActionID,newCalEventID);
}
}
else
{
//if ( LEN(TRIM(arguments.dateTimeID)) AND LEN(TRIM(arguments.hashID)) )
editTitle = "Edit the Event Series";
// If we are editing the SERIES... then use the SereisDatapageID from the Main event and just display the edit Event form
if ( StructKeyExists(arguments,"seriesDataPageID") AND IsNumeric(arguments.seriesDataPageID) AND arguments.seriesDataPageID GT 0 )
eventDataPageID = arguments.seriesDataPageID;
if ( LEN(TRIM(arguments.seriesEventID)) )
callbackActionID = arguments.seriesEventID;
}
if ( arguments.appDebug )
{
application.ptCalendar.utils.doDump(arguments,"arguments",0);
application.ptCalendar.utils.doDump(createEventStruct,"createEventStruct",0);
application.ptCalendar.utils.doDump(eventDataPageID,"eventDataPageID",1);
application.ptCalendar.utils.doDump(callbackAction,"callbackAction",1);
application.ptCalendar.utils.doDump(callbackActionID,"callbackActionID",1);
}
if ( variables.eventStepLogging )
{
doStepLogging(processName=logProcess,methodName="",logMsg="arguments",logData=arguments);
doStepLogging(processName=logProcess,methodName="",logMsg="createEventStruct",logData=createEventStruct);
logMsg = "editBean: " & editBean;
doStepLogging(processName = logProcess, methodName = "", logMsg = logMsg, addBreak = false, size = 60);
logMsg = "editMethod: " & editMethod;
doStepLogging(processName = logProcess, methodName = "", logMsg = logMsg, addBreak = true, size = 60);
logMsg = "eventDataPageID: " & eventDataPageID;
doStepLogging(processName = logProcess, methodName = "", logMsg = logMsg, addBreak = false);
logMsg = "callbackAction: " & callbackAction;
doStepLogging(processName = logProcess, methodName = "", logMsg = logMsg, addBreak = false);
logMsg = "callbackActionID: " & callbackActionID;
doStepLogging(processName = logProcess, methodName = "", logMsg = logMsg, addBreak = true, size = 60);
}
An event could NOT be found!
The Event Edit form CAN NOT be opened!
if ( !arguments.appDebug )
{
// Open the Event form... either directly as the Event Group/Series or as a new Event as new dataTime event with an occurrence exception
retHTML = application.ptCalendar.calEventsForms.renderEventFormForwarder(
bean=editBean
,method=editMethod
,dataPageID=eventDataPageID
,lbTitle=editTitle
,appcallback=callbackAction
,cbIDlist=callbackActionID
,appDebug=arguments.appDebug
);
/*,lbAction=editLBAction*/
}
return retHTML;
var retHTML = "";
var appConfig = getAppConfig();
var uiTheme = getUItheme();
var useEventsCache = false;
var deleteBean = "calEventsForms";
var deleteMethod = "renderEventDeleteForm";
var deleteTitle = "Delete the Event?";
var deleteConfirmBean = "calEventsForms";
var deleteConfirmMethod = "renderDeleteSeriesConfirmHTMLForm";
var deleteConfirmTitle = "Delete this Series of Events?";
var deleteCallback = arguments.callback;
var deleteCallbackIDList = "";
var currData = StructNew();
var seriesDataQry = QueryNew("temp");
var eventDataPageID = "";
var eventParentID = "";
var eventRecurrenceID = "";
var addExceptionStruct = StructNew();
var doCloseAndRefresh = false;
var doSeriesYesNoConfirm = false;
var doSeriesExceptionsDelete = false;
var noIDMsg = "";
var closeRefreshJS = "";
if ( arguments.appDebug )
application.ptCalendar.utils.doDump(arguments,"arguments",0);
// Get Current Occurrence and Series IDs for the selected event (so we don't have to pass so many hidden value from the FORM)
currData = application.ptCalendar.calEventsSeriesService.getOccurrenceData(
hashid=TRIM(arguments.hashID)
,dateTimeID=TRIM(arguments.dateTimeID)
,useCache=useEventsCache
);
if ( arguments.appDebug )
application.ptCalendar.utils.doDump(currData,"currData",0);
// Delete and/or create an exception for an occurrence of the event
if ( arguments.editSeriesOption EQ "occurrence")
{
if ( LEN(TRIM(arguments.dateTimeID)) AND LEN(TRIM(arguments.hashID)) )
{
// If the event has both DateTimeID and a HashID
// - This is an event Exception
// - Use the occurence DataPageID and delete the specific occurrence
deleteTitle = "Delete this Event Occurence";
// If we are deleting the OCCURENCE... then use the Occurrence DatapageID delete
if ( StructKeyExists(currData,"occurrDataPageID") AND IsNumeric(currData.occurrDataPageID) AND currData.occurrDataPageID GT 0 )
eventDataPageID = currData.occurrDataPageID;
// Add an exception for the deleted Occurrence to the Parent EventID
if ( StructKeyExists(currData,"occurrEventID") AND LEN(TRIM(currData.occurrEventID)) )
deleteCallbackIDList = currData.occurrEventID;
}
else if ( LEN(TRIM(arguments.dateTimeID)) )
{
// If the event has ONLY an dateTimeID value
// - This is a static date/time event
// - Delete only this dataTime record .... unless it is the last dateTime record and there are NO recurrence props
deleteTitle = "Delete the Event TEST";
if ( StructKeyExists(arguments,"occurrDataPageID") AND IsNumeric(arguments.occurrDataPageID) AND arguments.occurrDataPageID GT 0 )
eventDataPageID = arguments.occurrDataPageID;
if ( StructKeyExists(currData,"occurrEventID") AND LEN(TRIM(currData.occurrEventID)) )
deleteCallbackIDList = currData.occurrEventID;
}
else if ( LEN(TRIM(arguments.hashID)) )
{
// If deleting the occurrence of a event recurrence pattern...
deleteTitle = "Delete this Event Occurence";
// - add the dtHashID to the parent event recurrence record recurrence exception list
if ( StructKeyExists(currData,"seriesRecurrenceID") AND LEN(TRIM(currData.seriesRecurrenceID)) ) {
addExceptionStruct = application.ptCalendar.calEventRecurrenceService.saveExcludedHashIDs(
recurrenceID=TRIM(currData.seriesRecurrenceID)
,hashID=TRIM(arguments.hashID)
);
}
// - NO EVENT TO DELETE
// - TODO: recreate a YES/NO confirmation lightbox
// - NO need to pass any IDs back to the callback
// - JUST DO A CLOSE LB AND REFRESH PARENT
if ( StructKeyExists(addExceptionStruct,"CONTENTUPDATED") AND addExceptionStruct.CONTENTUPDATED EQ true ) {
doCloseAndRefresh = true;
}
}
}
else
{
deleteTitle = "Delete the Event Series";
// If we are deleting the SERIES... then use the SereisDatapageID from the Main event and just display the delete Event form
if ( StructKeyExists(currData,"seriesDataPageID") AND IsNumeric(currData.seriesDataPageID) AND currData.seriesDataPageID GT 0 )
eventDataPageID = currData.seriesDataPageID ; //& "00"
if ( StructKeyExists(currData,"seriesEventID") AND LEN(TRIM(currData.seriesEventID)) )
eventParentID = currData.seriesEventID;
if ( StructKeyExists(currData,"seriesRecurrenceID") AND LEN(TRIM(currData.seriesRecurrenceID)) )
eventRecurrenceID = currData.seriesRecurrenceID;
// Display YES/NO confirmation box
doSeriesYesNoConfirm = true;
doSeriesExceptionsDelete = true;
}
if ( arguments.appDebug )
{
application.ptCalendar.utils.doDump(arguments,"arguments",0);
application.ptCalendar.utils.doDump(addExceptionStruct,"addExceptionStruct",0);
application.ptCalendar.utils.doDump(eventDataPageID,"eventDataPageID",1);
}
// Load the jQuery scripts
application.ptCalendar.scripts.loadJQuery();
application.ptCalendar.scripts.loadADFLightbox(force=true);
// Include the Calendar Admin Style Sheet
application.ptCalendar.calService.loadCalendarAdminCSS();
An event could NOT be found!
The Event CAN NOT be DELETED!
if ( !arguments.appDebug )
{
if ( doCloseAndRefresh )
{
retHTML = renderEventConfirmFormProcessingMsg();
// Load the inline JavaScript after the libraries have loaded
application.ptCalendar.scripts.addFooterJS(closeRefreshJS, "TERTIARY"); // PRIMARY, SECONDARY, TERTIARY
}
else if ( doSeriesYesNoConfirm )
{
// Open a Yes/No Confirmation Box
retHTML = application.ptCalendar.calEventsForms.renderEventFormForwarder(
bean=deleteConfirmBean
,method=deleteConfirmMethod
,lbTitle=deleteConfirmTitle
,seriesID=eventParentID
,includeExceptions=doSeriesExceptionsDelete
,appDebug=arguments.appDebug
);
//,occurrenceID=eventParentID
}
else
{
// Open the Event form... either directly as the Event Group/Series or as a new Event as new dataTime event with an occurrence exception
retHTML = application.ptCalendar.calEventsForms.renderEventFormForwarder(
bean=deleteBean
,method=deleteMethod
,dataPageID=eventDataPageID
,lbTitle=deleteTitle
,callback=deleteCallback
,cbIDlist=deleteCallbackIDList
,appDebug=arguments.appDebug
);
}
}
return retHTML;
var retHTML = "";
var appConfig = getAppConfig();
var uiTheme = getUItheme();
var useEventsCache = getEventCacheStatus();
var deleteSeries = StructNew();
var deleteStatus = false;
var deletedEventIDList = "";
var doCloseAndRefresh = false;
var noIDMsg = "";
var closeRefreshJS = "";
// Call a function that gets:
// 1) The Parent EventDetails uniqueID and DataPageID
// - Gets The Child RecurrenceID (and datapageID)
// - Gets all the children DataTimeIDs and datapageIDs
// 2) The Exception EventsDetails uniqueID and DataPageID
// - Gets The Child RecurrenceID (and datapageID)
// - Gets all the children DataTimeIDs and datapageIDs
if ( LEN(TRIM(arguments.seriesID)) )
deleteSeries = application.ptCalendar.calEventsSeriesService.deleteEventSeriesAndChildrenByParentID(parentEventID=arguments.seriesID);
if ( !StructIsEmpty(deleteSeries) )
{
if ( StructKeyExists(deleteSeries,"deletedEventIDs") AND LEN(TRIM(deleteSeries.deletedEventIDs)) )
{
deletedEventIDList = deleteSeries.deletedEventIDs;
deleteStatus = true;
}
else
{
deleteStatus = false;
}
}
else
{
deleteStatus = false;
}
// if using cache and delete status is TRUE then clear the cache for this seriesID (parent eventID)
if ( useEventsCache AND deleteStatus AND LEN(TRIM(deletedEventIDList)) )
{
// the cache delete process can handle string if EventIDs
cleanupEventsCache = application.ptCalendar.calEventsCacheController.processEventCacheByEventID(eventID=deletedEventIDList,process="delete");
}
// Load the jQuery scripts
application.ptCalendar.scripts.loadJQuery();
application.ptCalendar.scripts.loadADFLightbox(force=true);
// Include the Calendar Admin Style Sheet
application.ptCalendar.calService.loadCalendarAdminCSS();
An event could NOT be found!
The Event Series CAN NOT be DELETED!
// Load the inline JavaScript after the libraries have loaded
application.ptCalendar.scripts.addFooterJS(closeRefreshJS, "TERTIARY"); // PRIMARY, SECONDARY, TERTIARY
if ( arguments.appDebug )
{
application.ptCalendar.utils.doDump(arguments,"arguments",0);
application.ptCalendar.utils.doDump(deletedEvents,"deletedEvents",0);
}
var retMsg = "";
var retStruct = StructNew();
var useEventsCache = false;
// TODO: ONLY use this when Events Cache is dyanmic and is always current
// var useEventsCache = application.ptCalendar.getEventCacheStatus();
var parentDataQry = QueryNew("temp");
var parentDataStruct = StructNew();
var parentEventID = "";
var parentRecurrenceID = "";
var newCalEventID = "";
var newDateTimeID = "";
var newEventDataPageID = "";
var recurrenceUpdated = StructNew();
var eventCreated = StructNew();
var dateTimeCreated = StructNew();
var updateNewEvent = StructNew();
doStepLogging(processName="Edit-Event",methodName="calEventsConfirmController.createExceptionEvent",logMsg="",addBreak=false);
/* START - STEPS */
// 1) Get the event data based on the HashID (don't use cache... unless Cache is up to date)
// 2) Update the Recurrence Record 'excludedDThashIDlist' with the hashID from the orginal event occurrence
// 3) Create a new event in the event details element using the srcEvent Data
// - Grab the calEventID
// - Grab the new calEventID
// 4) Create a new date/time record in the dateTime element using the date/Time info from the srcData
// - Update the dtHashID in the dateTime element record with the hashID
// - Grab the dateTimeID
// 5) Update the new Event Details record with the new DateTimeID
// - Grab the dataPageID of the new event record
// 6) Go back to the calling function using the datapageID and open the edit event form with the new event data
/* END - STEPS */
// 1) Get the event data based on the HashID (DO NOT use cache)
// - TODO: When the Events Cache can be dynamically updated and is always current this can be changed to use the 'useEventsCache' variable
parentDataQry = application.ptCalendar.calEventsDAO.getEvents(hashID=arguments.hashID,useCache=useEventsCache);
if ( parentDataQry.RecordCount )
{
// Get the data from the first row of the query as a structure
parentDataStruct = application.ptCalendar.data.queryRowToStruct(query=parentDataQry,rowNum=1);
// Get the calEventID
if ( StructKeyExists(parentDataStruct,"calEventID") )
parentEventID = parentDataStruct.calEventID;
// Get the RecurrenceID
if ( StructKeyExists(parentDataStruct,"recurrenceID") )
parentRecurrenceID = parentDataStruct.recurrenceID;
// 2) Update the recurrence to add the hashID into the dtHash exception list
if ( LEN(TRIM(parentRecurrenceID)) AND LEN(TRIM(arguments.hashID)) )
{
recurrenceUpdated = application.ptCalendar.calEventRecurrenceService.saveExcludedHashIDs(
recurrenceID=parentRecurrenceID,
hashID=arguments.hashID
);
}
if ( StructKeyExists(recurrenceUpdated,"CONTENTUPDATED") AND recurrenceUpdated.CONTENTUPDATED EQ true )
{
retMsg = retMsg & 'The Occurrence was added as an exception to the Group.' & ' ';
retStruct.exceptionAdded = true;
}
else
{
retMsg = retMsg & 'Could not add the exception to the Group.' & ' ';
retStruct.exceptionAdded = false;
}
// 3) Create a new event record in the event details element using the event information for this occurrence
if ( retStruct.exceptionAdded AND !StructIsEmpty(parentDataStruct) )
{
eventCreated = application.ptCalendar.calEventDetailsService.createNewExceptionEventDetails(eventData=parentDataStruct);
}
if ( StructKeyExists(eventCreated,"CONTENTUPDATED") AND eventCreated.CONTENTUPDATED EQ true )
{
retMsg = retMsg & 'The exception event was created.' & ' ';
retStruct.eventCreated = true;
if ( StructKeyExists(eventCreated,"newEventID") AND LEN(TRIM(eventCreated.newEventID)) )
newCalEventID = eventCreated.newEventID;
}
else
{
retMsg = retMsg & 'The exception event could NOT be created.' & ' ';
retStruct.eventCreated = false;
}
// 4) Create a new dateTime record in the datetime element using the event information for this occurrence
if ( LEN(TRIM(newCalEventID)) AND !StructIsEmpty(parentDataStruct) )
{
dateTimeCreated = application.ptCalendar.calEventDateTimeService.createNewEventDateTime(
calEventID=newCalEventID
,parentRecurrenceID=parentRecurrenceID
,eventData=parentDataStruct
);
}
if ( StructKeyExists(dateTimeCreated,"CONTENTUPDATED") AND dateTimeCreated.CONTENTUPDATED EQ true )
{
retMsg = retMsg & 'The exception date/time was created.' & ' ';
retStruct.dateTimeCreated = true;
if ( StructKeyExists(dateTimeCreated,"newDateTimeID") AND LEN(TRIM(dateTimeCreated.newDateTimeID)) )
newDateTimeID = dateTimeCreated.newDateTimeID;
}
else
{
retMsg = retMsg & 'The exception date/time could NOT be created.' & ' ';
retStruct.dateTimeCreated = false;
}
// 5) Update the new Event Details record with the new DateTimeID
// - Grab the dataPageID of the new event record
if ( LEN(TRIM(newCalEventID)) AND LEN(TRIM(newDateTimeID)) )
{
updateNewEvent = application.ptCalendar.calEventDetailsService.updateCalEventDetailsDateTimeRecurrence(
uniqueID=newCalEventID
,dateTimeIDlist=newDateTimeID
);
}
if ( StructKeyExists(updateNewEvent,"CONTENTUPDATED") AND updateNewEvent.CONTENTUPDATED EQ true )
{
retMsg = retMsg & 'The exception event was updated.' & ' ';
retStruct.eventUpdated = true;
if ( StructKeyExists(updateNewEvent,"dataPageID") AND IsNumeric(updateNewEvent.dataPageID) AND updateNewEvent.dataPageID GT 0 )
newEventDataPageID = updateNewEvent.dataPageID;
}
else
{
retMsg = retMsg & 'The exception event could NOT be updated.' & ' ';
retStruct.eventUpdated = false;
}
if ( arguments.appDebug )
{
application.ptCalendar.utils.dodump(parentDataQry,"parentDataQry",0);
application.ptCalendar.utils.dodump(parentDataStruct,"parentDataStruct",0);
application.ptCalendar.utils.dodump(recurrenceUpdated,"recurrenceUpdated",0);
application.ptCalendar.utils.dodump(eventCreated,"eventCreated",0);
application.ptCalendar.utils.dodump(newCalEventID,"newCalEventID",1);
application.ptCalendar.utils.dodump(dateTimeCreated,"dateTimeCreated",0);
application.ptCalendar.utils.doDump(updateNewEvent,"updateNewEvent",0);
}
retStruct.newCalEventID = newCalEventID;
retStruct.newDataPageID = newEventDataPageID;
retStruct.msg = retMsg;
logMsg = "newCalEventID:" & newCalEventID;
doStepLogging(processName="Edit-Event",methodName="",logMsg=logMsg);
logMsg = "newEventDataPageID: " & newEventDataPageID;
doStepLogging(processName="Edit-Event",methodName="",logMsg=logMsg);
logMsg = "retMsg: " & retMsg;
doStepLogging(processName="Edit-Event",methodName="",logMsg=logMsg,addBreak=true,breakSize=40);
}
return retStruct;
var retMsgHTML = "";
var processStatusHTML = " Processing...";
#processStatusHTML#
Please wait while this action is being processed!!
(This window will close when the process has completed.)