var retMsg = ""; var retHTML = ""; var eventCopyResultFooterJS = ""; var lbFormURL = ""; var newCalEventID = ""; var copyEventDetails = StructNew(); var copyEventDatesTimes = StructNew(); var newDateTimeIDlist = ""; var copyEventRecurrence = StructNew(); var newRecurrenceIDlist = ""; var updateNewEvent = StructNew(); var newDataStruct = StructNew(); var newEventDataPageID = ""; var key = ""; var appConfig = getAppConfig(); var actionApp = getAppBeanName(); var lightBoxURL = application.ADF.lightboxProxy; var uiTheme = getUItheme(); var formBean = "calEventsForms"; var formMethod = "renderEventEditForm"; var editTitle = "Edit Copied Event"; var callbackAction = "updateEventCache_cbFunct"; var callbackActionID = ""; var useVerboseOutput = getVerboseOutputStatus(); //if ( useVerboseOutput ) // causes an issue with the copy process // arguments.appdebug = true; // STEP 1: Do the copy of the event record to get the NewEventID copyEventDetails = application.ptCalendar.calEventDetailsService.copyCalEventDetails(srcEventID=arguments.srcEventID); // Set the NewCalEventID value from the newly created event if ( StructKeyExists(copyEventDetails,"CONTENTUPDATED") AND copyEventDetails.CONTENTUPDATED EQ true ) { retMsg = retMsg & 'The Event was Copied.' & '
'; if ( StructKeyExists(copyEventDetails,"newEventID") AND LEN(TRIM(copyEventDetails.newEventID)) ) newCalEventID = copyEventDetails.newEventID; // STEP 2: (OPTIONAL) if we have dateTimeIDs copy the dateTime records for this event... using the NewEventID as the calEventID // - return a list of the NewDateTime IDs if ( arguments.datetimeCopy AND LEN(TRIM(arguments.srcDateTimeIDList)) AND LEN(TRIM(newCalEventID)) ) { copyEventDatesTimes = application.ptCalendar.calEventDateTimeService.copyCalEventDatesTimes( srcUUIDlist=arguments.srcDateTimeIDList ,calEventID=newCalEventID ); // Loop over the results struct and create a list of new datetime IDs for ( key in copyEventDatesTimes ) { if ( StructKeyExists(copyEventDatesTimes[key],"CONTENTUPDATED") AND copyEventDatesTimes[key].CONTENTUPDATED EQ true ) { newDateTimeIDlist = ListAppend(newDateTimeIDlist,key); } } // If records were created if ( ListLen(newDateTimeIDlist) GT 0 ) retMsg = retMsg & 'The Date Time Records were Copied.' & '
'; } // STEP 3: (OPTIONAL) if we have recurrenceIDs copy the recurrence records for this event... using the NewEventID as the calEventID // - return a list of NewRecurrenceIDs if ( arguments.recurrenceCopy AND LEN(TRIM(arguments.srcRecurrenceIDList)) AND LEN(TRIM(newCalEventID)) ) { copyEventRecurrence = application.ptCalendar.calEventRecurrenceService.copyCalEventRecurrence( srcUUIDlist=arguments.srcRecurrenceIDList ,calEventID=newCalEventID ); // Loop over the results struct and create a list of new datetime IDs for ( key in copyEventRecurrence ) { if ( StructKeyExists(copyEventRecurrence[key],"CONTENTUPDATED") AND copyEventRecurrence[key].CONTENTUPDATED EQ true ) { newRecurrenceIDlist = ListAppend(newRecurrenceIDlist,key); } } // If records were created if ( ListLen(newRecurrenceIDlist) GT 0 ) retMsg = retMsg & 'The Recurrence Record was Copied.' & '
'; } // STEP 4: Update the "New Event" with the NewdateTimeIDs and NewRecurrenceIDs if ( LEN(TRIM(newCalEventID)) AND ( LEN(TRIM(newDateTimeIDlist)) OR LEN(TRIM(newRecurrenceIDlist)) ) ) { updateNewEvent = application.ptCalendar.calEventDetailsService.updateCalEventDetailsDateTimeRecurrence( uniqueID=newCalEventID ,dateTimeIDlist=newDateTimeIDlist ,recurrenceIDlist=newRecurrenceIDlist ); if ( StructKeyExists(updateNewEvent,"CONTENTUPDATED") AND updateNewEvent.CONTENTUPDATED EQ true ) { retMsg = retMsg & 'The New Event was updated.' & '
'; } } // STEP 5: Get the pageID of the "New Event" to be able to open the new event in a form if ( LEN(TRIM(newCalEventID)) ) { newDataStruct = application.ptCalendar.calEventDetailsDAO.getEventDetailsDataByUniqueID(uniqueID=TRIM(newCalEventID)); if ( StructKeyExists(newDataStruct,"pageID") AND IsNumeric(newDataStruct.pageid) AND newDataStruct.pageid GT 0 ) newEventDataPageID = newDataStruct.pageid; } } // STEP 6: Build the "New Copied Event" URL to be opened in a LB form so the event can be modified if ( IsNumeric(newEventDataPageID) ) { /* Build the URL to open the new Event LB form */ lbFormURL = lightBoxURL; lbFormURL = lbFormURL & "?bean=#formBean#"; lbFormURL = lbFormURL & "&method=#formMethod#"; lbFormURL = lbFormURL & "&appName=#actionApp#"; lbFormURL = lbFormURL & "&datapageid=#newEventDataPageID#"; lbFormURL = lbFormURL & "&lbAction=#arguments.lbAction#"; lbFormURL = lbFormURL & "&title=#editTitle#"; lbFormURL = lbFormURL & "&appcallback=#callbackAction#"; lbFormURL = lbFormURL & "&cbIDlist=#newCalEventID#"; } // Load the Scripts resources application.ptCalendar.scripts.loadJQuery(); application.ptCalendar.scripts.loadJQueryUI(themeName=uiTheme); application.ptCalendar.scripts.loadADFLightbox(); // Include the Calendar Admin Style Sheet application.ptCalendar.calService.loadCalendarAdminCSS();
// Load the inline JavaScript after the libraries have loaded application.ptCalendar.scripts.addFooterJS(eventCopyResultFooterJS, "TERTIARY"); // PRIMARY, SECONDARY, TERTIARY if ( LEN(TRIM(retMsg)) ) retHTML = retMsg & retHTML; return retHTML;