}
+ // If we're asked to get registrant counts
if ($this->postProcAddRegistrantsCount) {
- // Get sum of all attendee counts
- $counts = $this->wpdb->get_row("
+ $counts = $this->getEventRegistrantCounts($result_data['id']);
+
+ // If we have counts, add them to the result
+ if ($counts && is_array($counts)) {
+ $result_data = array_merge($result_data, $counts);
+ }
+
+ }
+
+ return $result_data;
+ }
+
+ /*
+ * Get registrant count summary for an event
+ *
+ * @param integer $eventId ID of the reg_event record
+ *
+ * @return array Summary array of event counts
+ *
+ */
+ public function getEventRegistrantCounts($eventId = false)
+ {
+
+ // Get sum of all attendee counts
+ $countsData = $this->wpdb->get_row("
SELECT SUM(attendee_max) AS total, SUM(attendee_count) AS registered, SUM(attendees_pending) AS cartHold, SUM(attendees_available) AS curAvail
FROM ".GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX."reg_time
- WHERE reg_event = ".$result_data['id']
- , ARRAY_A);
+ WHERE reg_event = $eventId
+ ;", ARRAY_A);
+
+ $counts = array(
+ 'total' => $countsData['total'],
+ 'registered' => $countsData['registered'],
+ 'cartHold' => $countsData['cartHold'],
+ 'curAvail' => $countsData['curAvail'],
+ 'totalAvail' => $countsData['cartHold'] + $countsData['curAvail']
+ );
+
+ return $counts;
- $result_data['total'] = $counts['total'];
- $result_data['registered'] = $counts['registered'];
- $result_data['cartHold'] = $counts['cartHold'];
- $result_data['curAvail'] = $counts['curAvail'];
- $result_data['totalAvail'] = $counts['cartHold'] + $counts['curAvail'];
+ }
+
+ /*
+ * Completely remove registrations for a specific event
+ *
+ * WARNING: This function will completely remove any trace of registrations for
+ * an event. It does nothing to confirm that this should happen. The code calling
+ * this function is responsible for all necessary confirmation that this should
+ * be done.
+ *
+ * @param integer $eventId ID of the reg_event record
+ *
+ * @return boolean True if delete was successful
+ *
+ */
+ public function deleteRegEvent($eventId = false)
+ {
+ if (!$eventId) {
+ trigger_error("deleteRegEvent(): Called without ID", E_USER_NOTICE);
+ return false;
}
+ $eventId = ($eventId - 0);
+ if ($eventId <= 0) {
+ trigger_error("deleteRegEvent(): Called with bad ID: $eventId", E_USER_NOTICE);
+ return false;
+ }
+
+ // Make sure we have a reg_event record for this event
+ $eventData = $this->getEntry($eventId);
+ if (!$eventData || !is_array($eventData)) {
+ trigger_error("deleteRegEvent(): Unable to find reg_event entry for ID: $eventId", E_USER_NOTICE);
+ return false;
+ }
+
+ // List of SQL queries to delete all table entries for this registration event
+ $deleteSql = array(
+ "DELETE FROM ".GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX . "reg_request_registrant WHERE reg_event = $eventId",
+ "DELETE FROM ".GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX . "reg_request_rate WHERE reg_event = $eventId",
+ "DELETE FROM ".GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX . "reg_request_rate WHERE reg_event = $eventId",
+ "DELETE FROM ".GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX . "reg_request_event WHERE reg_event = $eventId",
+ "DELETE FROM ".GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX . "reg_rate WHERE reg_event = $eventId",
+ "DELETE FROM ".GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX . "reg_class WHERE reg_event = $eventId",
+ "DELETE FROM ".GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX . "reg_time_pending WHERE reg_event = $eventId",
+ "DELETE FROM ".GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX . "reg_time WHERE reg_event = $eventId",
+ "DELETE FROM ".GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX . "reg_event WHERE id = $eventId",
+ );
+
+ $this->wpdb->query("START TRANSACTION");
+
+
+ $fail = false;
+
+ // Run each delete query in sequence
+ foreach ($deleteSql as $sql) {
+
+ // If there hasn't been a failure yet (we don't want to run additional queries if there's already been a problem)
+ if (!$fail) {
+
+ // run this query
+ $res = $this->wpdb->query($sql);
+
+ /*
+ * Check if it failed.
+ *
+ * We need to test specifically against FALSE since wpdb->query()
+ * returns the number of records deleted, which could be 0.
+ */
+ if ($res === false) {
+ $fail = true;
+ trigger_error('deleteRegEvent(); Error deleting a reg_event: '.$this->wpdb->last_error, E_USER_NOTICE);
+ }
+
+ }
+ }
+
+ // If there was a failure, roll back all changes, otherwise complete the transaction.
+ if ($fail) {
+ $this->wpdb->query("ROLLBACK");
+ return false;
+ } else {
+ $this->wpdb->query("COMMIT");
+ }
+
+ return true;
- return $result_data;
}
/*
$regEventJSON = false;
$regClassesJSON = false;
$regTimesJSON = false;
+ $regEventDeleted = false;
// Get any provided option
if (isset($_REQUEST['option'])) {
break;
+ case 'delete':
+
+ $regEventDeleted = false;
+
+ // If we don't have a registration Event ID
+ if (!$regEventID) {
+ $messages[] = 'Request to delete registrations for an event but ID for this was not supplied.';
+ } else {
+
+ // Check if we received a confirmation override to delete a reg event that has completed registrations
+ if (isset($_REQUEST['deleteConfirmation']) && $_REQUEST['deleteConfirmation'] == 'DELETE') {
+
+ // Check that we have reg_event entry for this ID
+ $regEvent = $this->getEntry($regEventID);
+
+ if (!$regEvent) {
+ $messages[] = 'Request to delete registrations for an event but unable to find registration setup for this event.';
+ } else {
+
+ // Delete registrations for this event
+ $regEventDeleted = $this->deleteRegEvent($regEventID);
+
+ if (!$regEventDeleted) {
+ $messages[] = 'Attempt to delete registrations for this event failed. Nothing has been deleted';
+ }
+ }
+
+ } else {
+
+ }
+
+ }
+
+ if ($regEventDeleted) {
+
+ // Return status, any suggested view, and any data to controller
+ return array(
+ 'status' => true,
+ 'modelRedirect' => false,
+ 'view' => 'admin/registrations/registrationEventDeleted.html',
+ 'data' => array()
+ );
+ break;
+
+ }
+
+ // Registration event was not deleted so falling through to eventDashboard to display reasons or ask for confirmation
+
case 'eventDashboard':
$regEvent = $this->getEventConfig($regEventID, true, false, true);
break;
+
+
+ break;
+
case 'dashboard':
default:
<h1>{$regEvent.event_name}</h1>
{if $haveMessages}
- <div class="glm-error" style="font-size: 1.5rem; line-height: 1.5rem; margin-top: 1rem;">
+ <div class="glm-error" style="font-size: 1rem; line-height: 1rem; margin-top: 1rem;">
<i>Please Note:</i>
<UL>
{foreach $messages as $m}
</div>
</div>
<div class="glm-small-12 glm-large-4 glm-columns">
+ {if $regEvent.total > 0}
<div class="glm-row">
<div class="glm-small-12 glm-column">
<h3>Maximum Attendees:</h3>
{$regEvent.total}
</div>
</div>
+ {/if}
<div class="glm-row">
<div class="glm-small-12 glm-column">
<h3>Registered:</h3>
{$regEvent.registered}
</div>
</div>
+ {if $regEvent.total > 0}
<div class="glm-row">
<div class="glm-small-12 glm-column">
<h3>Cart Hold:</h3>
{$regEvent.totalAvail}
</div>
</div>
+ {/if}
</div>
{if apply_filters('glm_members_menu_members', true)}
{if is_array($r_link)}
<a class="button button-secondary glm-button" href="{$r_link.url|escape:'string'}">Edit {$r_link.title}</a>
{/if}
+
+ <div id="regEventDeleteButton" class="button button-secondary glm-button">Delete Registration Event</div>
+ <div id="regEventDeleteDialog" class="glm-dialog-box" title="Delete Registrations for this Event">
+ <center>
+ <h1 class="glm-error">WARNING!</h1>
+ <p class="glm-error">*** Entirely removes an Event from Registrations ***</p>
+ </center>
+ <p>
+ Continuing with this action will permanently remove this event from registrations including all configuration associated with it.
+ This will not remove the event listing, only the information on registrations for this event.
+ </p>
+ <p>
+ This action is
+ <span class="glm-error">NOT REVERSABLE</span>! After deletion, you will be required to re-enter all registration related
+ configuration information in order to have registrations for this event.
+ </p>
+ {if $regEvent.registered > 0}
+ <center>
+ <h3 class="glm-warning">ALSO NOTE!</h3>
+ <p class="glm-error">There have been {$regEvent.registered} registrations submitted for this event.</p>
+ </center>
+ <p>
+ Continuing with this action <span class="glm-error">will delete all registrations for this event</span>.
+ This will also remove these registrations from all reports. It's important that you print all reports and other information
+ you want to preserve for registrations for this event prior to deletion.
+ </p>
+ <p>
+ The only exception is that the registration request records will remain along with the summary that was displayed after checkout
+ for those requests. After this action, that will be the only historic record the the submission took place and it will not be
+ possible to search for these requests by event.
+ </p>
+ {/if}
+ <form href="{$thisUrl}">
+ <input type="hidden" name="page" value="glm-members-admin-menu-registrations-events">
+ <input type="hidden" name="option" value="delete">
+ <input type="hidden" name="regEventID" value="{$regEvent.id}">
+
+ <center>
+ <h3>Event: <span class="glm-warning">{$regEvent.event_name}</span></h3>
+ <p>To delete registrations for this event, enter exactly "DELETE" in the field below.</p>
+ <input type="text" name="deleteConfirmation" value="" placeholder="Enter 'DELETE' here." required>
+ <p>Then click this button</p>
+ <input type="submit" class="button button-primary glm-button" value="Remove this Event from Registrations">
+ </center>
+ </form>
+ </div>
+
</div>
</div>
</div>
var fullCalendarLoaded = false;
// If this is a time specific event, then display the calendar
- if ({$regEvent.time_specific.value}) {
+ if ({$regEvent.time_specific.value} +0) {
/*
* Initialize the Full Calendar
}
-
+
+ // Delete Dialog Box
+ $("#regEventDeleteDialog").dialog({
+ autoOpen: false,
+ width: 600,
+ resizable: true
+ });
+
+ // Delete Event Registrations Button
+ $('#regEventDeleteButton').on('click', function() {
+ $('#regEventDeleteDialog').dialog('open');
+ });
+
+
// Flash certain elements for a short time after display
$(".glm-flash-updated").fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500);
+
});
</script>
--- /dev/null
+{include file='admin/registrations/eventHeader.html'}
+
+<h1>Event removed from registrations.</h1>
+
+{include file='admin/footer.html'}
+